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 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: 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 allocation enables fast sequential reads but fragments disk; linked allocation eliminates fragmentation; indexed allocation consolidates block pointers into an index block.