Kernel Data Structures
Basic Concept

Kernel data structures 是 OS 用來追蹤 I/O state 的資料結構
One read() Can Mean Different Things
UNIX 把許多不同 entity 都放進 file-system style interface:普通檔案、raw device、socket、process image 等都可能支援 read()。但它們的實際語意不同:
- 讀 ordinary file:kernel 可能先查 buffer cache,再決定是否 disk I/O。
- 讀 raw disk:kernel 必須檢查 request size 是否是 sector size 的倍數,address 是否 sector-aligned。
- 讀 process image:可能只是從 memory copy data。
- 讀 socket:可能要檢查 network buffer 和 connection state。
所以 kernel 需要一套機制,讓同一個 system call 可以根據 object type dispatch 到不同 implementation。