Skip to main content

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​

MethodIdeaProsCons
ContiguousBlocks are adjacentFast sequential and direct accessExternal fragmentation, hard to grow
LinkedEach block points to the nextNo fragmentationSlow random access, pointer overhead
IndexedAn index block lists all blocksDirect access, no fragmentationIndex block overhead
Unix inodeDirect + indirect pointersEfficient for small and huge filesMore 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.

AlgorithmBehaviour
FCFSServe in arrival order
SSTFClosest request first (starvation possible)
SCAN (elevator)Sweep one direction, then reverse
C-SCANSweep one direction, jump back to start
LOOK / C-LOOKLike 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.