› Module 8: File Systems › 8.3 File Allocation Methods
M O D U L E

Module 8: File Systems

File concepts, access methods, directory structures, and disk block allocation

8.1 File Concepts & Access Methods

A file is a named collection of related data recorded on secondary storage — the uniform logical storage unit abstracted by the operating system over physical disks. The mechanism by which records within a file are read or written is called its access method.

Figure 8.1: Sequential Access (Tape Model) vs. Direct / Random Access (Disk Model) Sequential Access (In Order) R1 R2 R3 R4 R5 R6 Records read/written strictly in order Direct / Random Access (Relative Block) R1 R2 R3 R4 R5 R6 Jumps straight to block #4 (e.g. read_block(4)) Indexed Access: Builds on direct access using index search keys to map directly to relative block pointers.

Figure 8.1: Sequential access processes records in order like magnetic tape; direct access allows immediate seeks to any block index like random-access storage.

Access Methods Compared

  • Sequential Access: The simplest and most common method. Data is processed in order, one record after another (natural for compilers, stream decoders, and audio playback).
  • Direct (Relative) Access: Files are composed of fixed-length logical records that can be read or written in any order using a relative block number (essential for relational database index lookups).
  • Indexed Access: A separate index is maintained containing pointers to various blocks, allowing fast lookups without full-file sequential scans.

8.2 Directory Structures

The directory acts as a symbol table mapping human-readable file names to their corresponding physical metadata blocks (such as UNIX inodes or Windows MFT records). The structural organization of directories determines naming flexibility and file sharing capabilities.

Figure 8.2: Tree-Structured Hierarchical Directory Organization / /home /bin /etc /var /alice /bob notes.txt photo.jpg Absolute Path: /home/alice/notes.txt • Relative Path: notes.txt (from current dir)

Figure 8.2: A tree-structured directory isolates user files into private subtrees while supporting absolute and relative path resolution.

Evolution of Directory Models

  • Single-Level Directory: All files in the same directory. Cannot handle multiple users due to inevitable name collisions.
  • Two-Level Directory: Separate directory for each user. Solves multi-user collision, but users cannot group their own files into subdirectories.
  • Tree-Structured Directory (Standard): Arbitrary levels of nesting. Root directory with recursive subdirectories.
  • Acyclic-Graph Directory: Supports shared files and directories via links (UNIX hard links and soft/symbolic symlinks). Requires reference-counting to avoid dangling pointer deletions.

8.3 File Allocation Methods

An allocation method defines how secondary storage disk blocks are assigned to files to maximize space utilization and minimize disk head seek latencies.

Figure 8.3: Contiguous, Linked, and Indexed File Block Allocation Strategies 1. Contiguous Allocation Start: Block 1, Length: 3 0 1 2 3 4 ✓ Fast seek | ✗ External Frag 2. Linked Allocation Blocks point to next block Blk 9 Blk 2 Blk 16 Blk -1 ✓ No Frag | ✗ Slow Random 3. Indexed Allocation Single Index Block holds pointers Index Block [0, 1, 2, 3] B 14 B 2 B 27 B 8 ✓ Direct Access | UNIX Inode

Figure 8.3: Contiguous allocation enables fast sequential reads but fragments disk; linked allocation eliminates fragmentation; indexed allocation consolidates block pointers into an index block.

MODULE COMPREHENSIVE QUIZ

Module 8 Final Quiz

Test your understanding across all 3 topics of this module with interview-grade questions, tricky edge cases, and code output predictions.

Take Module 8 Final Quiz →
Yukti Mascot