Linked Allocation

Linked allocation 把 file 實作成 blocks 的 linked list;directory / FCB 通常記 first block、last block。

directory entry → block 9 → block 16 → block 1 → block 10 → EOF

任何 free block 都能接到 file 尾端,因此 file 容易成長,也沒有 external fragmentation。

Operations

Append new block:

  1. Free-space manager 找 free block。
  2. 寫入 data。
  3. 舊 last block 的 next pointer 指向新 block。
  4. 更新 FCB 的 last pointer 與 size。

Sequential read 只要沿 pointer 前進;random access 則必須從頭追 pointer,所以很弱。

D-OS-Ch14dba-File_Allocation_Table 是重要變形:把 next pointers 集中放到 table,不放在 data blocks 裡。