operating systems: kernel vs userland
processes: essentially a running program
threads: concurrent paths of execution within single process
filesystems
networking
TODO: diagram
indirect index: trie-like data structure (aka radix tree)
suppose index block holds 256 (28) (radix block pointers)
TODO: diagram
block_num / 256<sup>2</sup>
(or block_num >> 16
)block_num / 256 mod 256 (or
block_num >> 8 & 0xff )level 3 offset: blocknum mod 256
(or block_num & 0xff
)
three levels of lookup:
level2block = getblock(level1[offset1]) level3block = getblock(level2[offset2]) data = get-block(level3[offset3])
example: suppose:
M
block addresses (e.g. 64, 128, 256)
bM
bits (6, 7, 8)mM
mask (0x3f, 0x7f, 0xff) mM = (1 << bM) - 1
d
direct pointers (e.g. 3, 5, 10)i
index pointers (e.g. 2, 3, 4)i2
double indirect pointers (e.g. 2, 3, 4)i3
triple indirect pointers (e.g. 1, 2, 3)to find block address for given block number:
if blockknum < d return direct_pointer[blocknum]
blocknum -= d if blocknum < i * M indexblock = indirectpointer[blocknum / M] (or: indexblock = indirectpointer[blocknum >> bM]) return indexblock[blockNum % M] (or: return indexblock[blockNum & mM])
blocknum -= i * M if blocknum < i2 * M * M indexblock1 = doubleindirectpointer[blocknum / (M*M)] (or: indexblock1 = doubleindirectpointer[blocknum >> (2 * M)]) indexblock2 = indexblock1[(blocknum >> M) & mM] return index_block2[blocknum & mM]
blocknum -- i2 * M * M indexblock1 = tripleindirectpointer[blocknum / (M * M * M)] indexblock2 = indexblock1[blocknum / (M * M) % M] indexblock3 = indexblock2[blocknum / M % M] return indexblock3[blocknum % M]
Boolean identities:
x & 0 = 0
(clear)x & 1 = x
(keep)x | 0 = x
(keep)x | 1 = 1
(set)x ~ 0
= x` (keep)x ~ 1
= ~x` (toggle)Bitwise operations treat a word as a vector of individual bits. A bit field is (contiguous) a group of 1 or more bits in a word. The bit field may be extracted by shifting to the right and clearing the bits outside the field (or clearing first, then shifting).
strength reduction is the replacement of expensive operations by less-expensive ones
depending on the architecture, multiplication, division and remainder are relatively expensive operations
x * 2<sup>n</sup>
can be replaced by x << n
x / 2<sup>n</sup>
can be replaced by x >> n
x mod 2<sup>n</sup>
can be replaced by x & (n - 1)
blocks contain data only
index node (inode) contains the address at block 0 (1st block)
global FAT is an array of block addresses
there is a 1:1 correspondence between blok addresses & FAT array indexes
TODO: diagram