Professional Documents
Culture Documents
CH 14
CH 14
Implementation
LA/512
Block to be accessed = Q +
starting address
Displacement into block = R
FAT (MS-DOS)
Mapping
Q
LA/511
R
Block to be accessed is the Qth block in the linked chain
of blocks representing the file.
Indexed allocation
Each file has its own index block(s) of pointers to its data
blocks
Logical view
index table
Null
Random access
Q1
LA / (512 x 511)
R1
Q1 = block of index table
R1 is used as follows:
Q2
R1 / 512
R2
Q1
LA / (512 x 512)
R1
1 Disk blocks
File header 2
1
2
3 11
11 266
267
12 256
13
256
256
256
256 256
256
256
On disk
Base size
File header
Block group
Each “block group” – a contiguous region of blocks
Are 10 block group pointers enough?
No. If need more than 10 block groups, set flag in file header:
BIGFILE.
Operating System Concepts – 10 th Edition 14.40 Silberschatz, Galvin and Gagne
DEMOS
Each table entry now points to an indirect block group – a block
group of pointers to block groups.
On disk
Base size
File header
Block group
Indirect block group
Can get huge files this way: Suppose 1000 blocks in a block
group, each block 8K size, each entry 8 byte => (10 ptrs1024
groups/ptr1000 blocks/group)*8K =80 GB max file size
How do you find an available block group?
Use bit map to find block of 0’s
Operating System Concepts – 10 th Edition 14.41 Silberschatz, Galvin and Gagne
DEMOS
Pros & cons:
+ Fast sequential access
+ Easy to find free block groups
+ Free areas merge automatically
– When disk fills up:
a. No long runs of blocks (fragmentation)
b. High CPU overhead to find free block
Solution:
Don’t let disk get full – keep portion in reserve
Free count = # blocks free in bitmap.
Normally, don’t even try allocate if free count = 0.
Change this to: don’t allocate if free count < reserve
Why do this?
Tradeoff: pay for more disk space, get contiguous allocation
How much of a reserve do you need?
In practice, 10% seems like enough.
More index blocks than can be addressed with 32-bit file pointer
0 1 2 n-1
…
1 block[i] free
bit[i] =
0 block[i] occupied
Counting
Because space is frequently contiguously used and freed,
with contiguous-allocation allocation, extents, or clustering
Keep address of first free block and count of following
free blocks
Free space list then has entries containing addresses
and counts
These entries can be stored in a balanced tree, rather
than a linked list, for efficient lookup, insertion, and
deletion.