File Systems and I/O
Files and directories
A file is a named collection of related data. The file system provides naming, storage layout, access control and metadata.
Metadata (inode)
On Unix-like systems each file has an inode with: owner, permissions, size, timestamps and pointers to data blocks. The file name lives in a directory entry that points to the inode.
Allocation methods
| Method | Idea | Pros | Cons |
|---|---|---|---|
| Contiguous | Blocks are adjacent | Fast sequential and direct access | External fragmentation, hard to grow |
| Linked | Each block points to the next | No fragmentation | Slow random access, pointer overhead |
| Indexed | An index block lists all blocks | Direct access, no fragmentation | Index block overhead |
| Unix inode | Direct + indirect pointers | Efficient for small and huge files | More complex |
Free-space management
Bitmap (one bit per block), linked list of free blocks, grouping, counting.
Directory structures
Single-level, two-level, tree-structured (most common), and acyclic graph (links). Hard links share an inode; symbolic links store a path.
Access control
Unix permissions are rwx for owner / group / others.
chmod 640 notes.txt # owner: rw-, group: r--, others: ---
ls -l notes.txt
Disk scheduling
Minimise head movement for a queue of block requests.
| Algorithm | Behaviour |
|---|---|
| FCFS | Serve in arrival order |
| SSTF | Closest request first (starvation possible) |
| SCAN (elevator) | Sweep one direction, then reverse |
| C-SCAN | Sweep one direction, jump back to start |
| LOOK / C-LOOK | Like SCAN/C-SCAN but only to the last request |
I/O techniques
- Polling: CPU repeatedly checks the device.
- Interrupt-driven: the device signals completion.
- DMA: a controller moves data to memory without the CPU; the CPU is interrupted once.
Loading Comments...