Autumn 2026 All AIOU Solved Assignments, Key Books & 8613 Projects Live!
100% Free Online Reading • Copy & Download Disabled
AIOU LIBRARY KEY BOOK Course Code 3400 • BS Computer Science (BSCS) 🇬🇧 English Medium

AIOU Code 3400: Introduction to Computing — Complete Helping Key Book & Exam Guide

Read chapter-by-chapter summaries, solved self-assessment exercises, past paper long questions, and solved MCQs directly on AIOU Library. Free of cost for all AIOU students.

Published Units: 9 / 9 Units
← Course Hub

AIOU LIBRARY • READ ONLY

AIOULIBRARY.COM • CODE 3400

AIOU LIBRARY • DO NOT COPY

Unit 6 of 9 • Verified Key Book Authored by AIOU Library Academic Engine • 9248 Words

Unit 6: File Systems and Storage Management

Part 1: Comprehensive Unit Summary & Core Concepts

Easy Chapter Introduction & Learning Objectives

Welcome to Unit 6 of Course 3400: Introduction to Computing. In our previous units, we explored how the operating system manages the computer's CPU and main memory (RAM). However, RAM is temporary; whenever you switch off your computer or mobile phone, everything stored in RAM is lost. To save your documents, photos, software, and operating system files permanently, the computer uses secondary storage devices such as Hard Disk Drives (HDDs), Solid State Drives (SSDs), and USB flash drives.

Managing this secondary storage is one of the most important jobs of an Operating System (OS). This job is known as File Systems and Storage Management. Imagine a massive physical library with millions of books. If books were just thrown into piles on the floor, nobody would ever find anything. A library needs shelves, sections, catalog numbers, a librarian, and rules for borrowing. Similarly, a file system is the librarian of your computer's storage. It organizes data into neat files and folders, tracks where they are saved on the disk, protects them from unauthorized users, and ensures that multiple programs do not mess up the same data.

By the end of this comprehensive unit study guide, distance-learning students of Allama Iqbal Open University (AIOU) will be able to:

  • Define what a file is, along with its core attributes and naming conventions.
  • Understand different file access methods (Sequential and Direct Access) and directory structures.
  • Explain how file systems are mounted onto a directory tree and how file protection and access control lists work.
  • Compare the three main file allocation methods: Contiguous, Linked, and Indexed allocation.
  • Describe how operating systems keep track of available storage using Free-Space Management techniques.
  • Analyze and solve problems related to Disk Scheduling Algorithms (FCFS, SSTF, SCAN, C-SCAN).
  • Define key technical terms related to storage management clearly and confidently for exams.

Detailed Explanation of Every Unit Topic

1. File Concept and File Attributes

To a computer user, a file is simply a digital document, a song, a video, or an application. But to an operating system, a file is a named collection of related information recorded on secondary storage. The OS hides the complex hardware details of how disks spin or how magnetic charges are placed, and instead presents a clean, uniform logical view of information through files.

Every file stored on a computer has a set of properties known as File Attributes (or metadata). These attributes tell the operating system and the user essential details about the file:

  • Name: The human-readable identifier of the file (e.g., assignment1.docx).
  • Identifier: A unique numerical tag (number) used by the file system internally to track the file, because computers handle numbers much faster than text names.
  • Type: Indicates the format of the file so the OS knows which program to open it with (e.g., PDF, MP3, EXE). Often represented by a file extension.
  • Location: A pointer or address showing exactly where the file is stored on the physical disk device.
  • Size: The current size of the file, usually measured in bytes, kilobytes (KB), megabytes (MB), or gigabytes (GB).
  • Protection/Permissions: Rules defining who can read, write, or execute the file (e.g., Owner, Group, Public).
  • Time, Date, and User Identification: Timestamps recording when the file was created, when it was last modified, and when it was last accessed, along with the user ID of who performed these actions.

Real-Life Pakistani Example: Think of a file like an official file folder in a government office in Islamabad. The folder has a case number (Identifier), a title written on the cover (Name), a category like 'Tax Records' (Type), a specific shelf in the archive room (Location), page counts (Size), stamps showing who is allowed to open it (Protection), and dates of when letters were added (Timestamps).

2. Access Methods and Directory Structure

Once files are created and stored, the operating system must provide ways to read and write data inside them. These are called File Access Methods:

  • Sequential Access: Data in the file is processed in a fixed, chronological order, one record after another. If you want to read record number 50, the computer must read records 1 through 49 first. Example: An audio cassette tape or a traditional music playlist where you must press 'Next' multiple times to reach a specific song.
  • Direct Access (or Random Access): Data can be read or written immediately in any random order without reading preceding records. The file is viewed as a numbered sequence of blocks or records. Example: A music track on a digital smartphone or computer where you can click directly on the 3rd minute of a song to play it instantly.

To organize thousands or millions of files, operating systems use a Directory Structure. A directory is essentially a node or a folder that keeps track of files. Over the evolution of computing, several directory structures have been used:

  • Single-Level Directory: All files are contained in one single directory for all users. It is simple, but if two different students name their document notes.txt, the system will crash or overwrite one file because names must be unique.
  • Two-Level Directory: The system creates a separate directory for each individual user. User A can have notes.txt and User B can also have notes.txt because their personal master directories separate them.
  • Tree-Structured Directory (Most Common): A hierarchical structure resembling an inverted tree. It starts at a root directory, which contains subdirectories (folders) and files. Users can create unlimited subdirectories to organize work. Example: C:\AIOU\Course3400\Unit6\notes.docx.
  • Acyclic-Graph Directory: A tree structure that allows subdirectories and files to be shared between different folders using links or shortcuts, avoiding file duplication while maintaining an organized tree appearance.

3. File System Mounting and Protection

Have you ever plugged a USB flash drive into your laptop and watched the computer make a sound and show a new drive letter like `E:`? That process is called File System Mounting.

A file system cannot be used immediately until it is 'mounted' to the operating system's main directory tree. The operating system needs to know where the new storage device fits into the existing file structure. When you mount a USB drive, the OS attaches the root directory of the USB drive to an existing directory (called the mount point) on your computer's primary hard drive. Once mounted, all files on that USB become accessible through that folder path. When you are done, you 'unmount' or safely eject the drive so the OS closes all file connections cleanly without data corruption.

Because computers are often shared by multiple users or connected to networks, File Protection and Security are vital:

  • Access Control List (ACL): A detailed list attached to a file that specifies exactly which users or groups have access permissions, and what specific operations they are allowed to perform.
  • Core Permissions: Typically divided into three basic operations:
    • Read (R): Permission to read or view the contents of a file.
    • Write (W): Permission to modify, append, or overwrite the contents of a file.
    • Execute (X): Permission to run the file as a program or script.
  • User Categories: Permissions are usually categorized into three groups:
    • Owner: The user who created the file and has full control.
    • Group: A set of users sharing common access needs (e.g., university students in a specific department).
    • Universe/Public: Every other user on the system or network.

Real-Life Example: On a university computer lab desktop, a professor has Read, Write, and Execute access to grade sheets, teaching assistants have Read and Write access, while regular students have zero access to protect confidential grading records.

4. Allocation Methods (Contiguous, Linked, Indexed)

A hard disk is divided into fixed-size blocks (often 512 bytes to 4KB each). When a user saves a 10MB file, the operating system must decide which disk blocks to use to store that file. This is called File Allocation. There are three primary methods:

  • Contiguous Allocation:

    In this method, each file occupies a set of contiguous (consecutive, back-to-back) blocks on the disk. If a file requires 4 blocks, the OS finds 4 empty blocks sitting right next to each other (e.g., blocks 5, 6, 7, and 8). The directory entry only needs to store the starting block address and the length of the file.

    • Advantages: Extremely fast reading speed because the disk head does not need to jump around; it reads straight across. Supports both sequential and direct access easily.
    • Disadvantages: Suffers from External Fragmentation. As files are created and deleted over time, free space gets broken up into small scattered gaps. You might have enough total free space on your hard drive, but no single continuous gap large enough to save a new large movie file. Also, files cannot easily grow in size if adjacent blocks are already occupied.
  • Linked Allocation:

    In this method, every file is stored as a linked list of disk blocks anywhere on the disk. The blocks do not need to be next to each other. Each block contains a pointer (a tiny memory address) pointing to the next block in the file. The directory entry contains a pointer to the very first block and the very last block of the file.

    • Advantages: No external fragmentation! Any free block on the disk can be used to store part of a file. Files can easily grow dynamically because you just grab another free block and update the pointer.
    • Disadvantages: Very poor performance for direct access. To find the 50th block of a file, the computer must start at block 1, read the pointer to block 2, read that pointer to block 3, and so on, walking through all previous blocks sequentially. Furthermore, if a single pointer gets corrupted or lost due to a bad disk sector, the rest of the file is lost.
  • Indexed Allocation:

    This method solves the problems of both contiguous and linked allocation by bringing all the pointers together into one central location called an Index Block. Every file has its own index block, which is an array of disk block addresses. The ith entry in the index block points to the ith block of the file. The directory entry simply points to the file's index block.

    • Advantages: Supports direct access efficiently without external fragmentation. You look up the index block, find the exact block number you need, and jump straight to it.
    • Disadvantages: Overhead of storage space. For small files, wasting an entire block just to store an index table is inefficient. If a file is extremely large, one index block may not be enough, requiring linked index blocks or multi-level indexes.

5. Free-Space Management

Since physical disk space is limited, the operating system must keep track of which disk blocks are empty (free) and which blocks are currently occupied by files. This system is known as Free-Space Management. Whenever a new file is created or an existing file grows, the OS checks its free-space records to allocate empty blocks. When a file is deleted, those blocks are marked back as free.

Common techniques used by operating systems to manage free space include:

  • Bit Vector (or Bitmap): The disk's free space is represented as a series of bits, where each bit corresponds to one disk block. If a block is free, its bit is set to 1. If the block is allocated, its bit is set to 0. Example: A disk with 4,000 blocks needs a bit map of only 4,000 bits (about 500 bytes), which can be kept very quickly in main memory. Finding the first free block is efficient by scanning for the first '1' bit.
  • Linked List: The operating system links all free disk blocks together in a continuous chain, keeping a pointer to the first free disk block in a special location on the disk or in memory. When a block is needed, the OS takes the first one off the chain. While it does not waste space with a bitmap, traversing the linked list can be slow if many free blocks are scattered.
  • Grouping: An improvement on the linked list method where the first free block stores the addresses of *n* free blocks. Out of those *n* blocks, *n-1* are actual free data blocks, and the last one points to the next group block. This allows rapid allocation of multiple blocks.
  • Counting: Instead of keeping a list of every single free block address, the OS keeps track of the starting address of a group of contiguous free blocks and the number of contiguous free blocks following it. This keeps the free-space table extremely compact.

6. Disk Scheduling Algorithms

Most computers today use traditional Hard Disk Drives (HDDs) which contain physical rotating magnetic platters and a mechanical read/write head mounted on a moving arm. When multiple programs request data from different parts of the disk at the same time, the mechanical disk arm must move back and forth across the platters to reach the requested tracks. Disk Scheduling is the method used by the operating system to decide the order in which disk I/O requests are serviced to minimize mechanical movement time and maximize efficiency.

The primary performance metric is Seek Time (the time taken for the disk arm to move to the correct track) and Rotational Latency. Here are the core disk scheduling algorithms you must master:

  • First-Come, First-Served (FCFS):

    Requests are serviced strictly in the order they arrive in the disk queue. It is extremely fair—no request is starved of service—but it is mechanically inefficient. If requests are scattered across opposite edges of the disk, the disk arm will thrash wildly back and forth, resulting in very high average seek times.

  • Shortest Seek Time First (SSTF):

    This algorithm selects the request that is closest to the current position of the disk head, regardless of arrival order. It drastically reduces total seek time compared to FCFS and increases system throughput.

    Disadvantage: It can cause starvation. If a steady stream of requests keeps arriving near the middle of the disk, a request sitting at the far outer edge of the disk might wait indefinitely while the head ignores it.

  • SCAN Algorithm (Elevator Algorithm):

    In the SCAN algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing every request it encounters along the way. When it reaches the far end of the disk, it reverses direction and moves back toward the opposite end, servicing requests in reverse. Just like an elevator in a tall building, it goes all the way to the top before turning around to service people going down.

    Advantage: Avoids the starvation problem of SSTF because every request is guaranteed to be serviced when the head sweeps past its track.

  • C-SCAN Algorithm (Circular SCAN):

    A variation of SCAN designed to provide a more uniform wait time. While SCAN reverses direction at the ends, C-SCAN treats the cylinders as a circular list that wraps around from the final cylinder back to the first cylinder. When the head reaches one end of the disk, it immediately returns to the opposite end of the disk without servicing any requests on the return trip, and then begins another sweep in the same direction.

    Advantage: Provides a much more uniform waiting time for requests across the entire disk surface compared to regular SCAN.

Key Terms & Easy Glossary

  • File: A named collection of related data or information recorded on secondary storage (such as a hard drive or USB) that is presented by the operating system as a single unified unit.
  • Metadata (File Attributes): Descriptive properties associated with a file, including its name, size, creator, creation date, permissions, and physical location on the disk storage.
  • Directory: A specialized organizational folder or catalog within a file system that holds references to other files and subdirectories, forming a structured hierarchy.
  • Mounting: The operating system process of attaching a secondary storage device (like a USB drive or CD-ROM) to an existing directory location (mount point) within the active file system tree so users can access its data.
  • Access Control List (ACL): A security mechanism that defines exactly which users, groups, or system processes are granted specific access privileges (Read, Write, Execute) to a particular file or folder.
  • Contiguous Allocation: A file storage method where all blocks comprising a file are stored next to each other in consecutive physical sectors on the disk, providing fast read speeds but risking external fragmentation.
  • Linked Allocation: A storage method where each file is stored as a scattered list of disk blocks, with every block containing a pointer address directing the system to the next block in the file sequence.
  • Indexed Allocation: A file allocation technique that gathers all physical block pointers of a file into a single designated table called an Index Block, allowing fast direct access without external fragmentation.
  • Free-Space Management: The operating system's internal method of tracking which storage blocks on a disk are currently empty and available for allocation, utilizing tools like bitmaps or linked lists.
  • Disk Scheduling: The algorithm used by an operating system to determine the optimal order in which read and write requests for a hard disk are processed to minimize mechanical arm movement and seek time.
Part 2: Solved Self-Assessment & Short Questions

Q: What are the primary attributes of a file, and how does the operating system maintain them?

Easy Answer: A file is a named collection of related information recorded on secondary storage. To manage files efficiently, the operating system associates a set of properties known as file attributes (or metadata) with each file. These attributes vary slightly across different operating systems, but the primary ones include:

  • Name: The human-readable string used to identify the file (e.g., document.txt).
  • Identifier: A unique tag, usually a number, that identifies the file within the file system (used internally by the OS).
  • Type: Information indicating the format of the file so that programs know how to read it (e.g., executable, text, image).
  • Location: A pointer or address pointing to the file's exact physical or logical location on the storage device.
  • Size: The current byte or block size of the file.
  • Protection (Permissions): Access control lists defining who can read, write, or execute the file.
  • Time, Date, and User Identification: Timestamps recording when the file was created, last modified, and last accessed, along with the ID of the user who created it.

How the OS Maintains Them: The operating system stores these attributes in a special data structure called a File Control Block (FCB) or inode (in UNIX-like systems). Whenever a file is created, the OS allocates an FCB and initializes these values. When a user requests file operations (like reading, writing, or changing permissions), the OS checks or updates the corresponding FCB stored on the disk.

Example: When you right-click a file in Windows and select "Properties," you are viewing its attributes (size, type, creation date, and read-only status), all of which are retrieved and maintained by the OS from the file's FCB.

Q: Compare and contrast sequential access and direct access methods for files.

Easy Answer: The file access method refers to the way data inside a file is read or written by the operating system. The two primary methods are sequential access and direct access (also known as random access).

  • Sequential Access Method:
    • How it works: Data is accessed in a strictly linear, one-record-after-another order. If you want to read record number 50, the OS must read records 1 through 49 first.
    • Underlying Hardware: Originally designed for magnetic tapes, where physical rewinding and fast-forwarding were required.
    • Pros & Cons: Very simple to implement and efficient when processing entire files (e.g., payroll batch processing). However, it is extremely slow for searching or modifying specific middle records.
  • Direct (Random) Access Method:
    • How it works: Data can be read or written in any order, immediately, without reading preceding records. Files are viewed as a numbered sequence of blocks or records.
    • Underlying Hardware: Ideal for disk drives (HDDs and SSDs), where the read/write head can jump directly to any sector.
    • Pros & Cons: Extremely fast for database queries, video streaming, or jumping to specific file offsets. However, it requires complex file system organization and block tracking.

Example: Listening to a cassette tape track by track is sequential access, whereas clicking a specific timestamp on a YouTube progress bar to jump directly to that part of the video is direct access.

Q: Explain the hierarchical directory structure and how absolute paths differ from relative paths.

Easy Answer: Modern operating systems organize files using a hierarchical directory structure (tree-like structure). At the very top is a root directory (represented by / in UNIX or C:\ in Windows). Under the root, there are subdirectories (folders), which can contain more folders (sub-folders) and files. This allows users to logically categorize their data (e.g., Documents, Music, Projects).

To locate a file within this tree, pathnames are used. There are two primary types of paths:

  • Absolute Path:
    • Definition: Specifies the exact location of a file starting from the root directory.
    • Characteristics: It always begins with the root symbol and remains valid no matter where the user is currently located in the file system.
    • Example: /home/user/documents/report.pdf (Linux) or C:\Users\Ali\Documents\report.pdf (Windows).
  • Relative Path:
    • Definition: Specifies the location of a file relative to the user's current working directory.
    • Characteristics: It does not start from the root. It uses shorthand notation like . (current directory) and .. (parent directory).
    • Example: If you are currently inside /home/user/documents/, the relative path to the report is simply report.pdf or ./report.pdf.

Example: Think of an absolute path as your complete home address (Country, City, Street, House Number), which works from anywhere in the world. A relative path is like giving directions from your current room ("go two doors down the hall"), which only works if you are already inside that house.

Q: What is file system mounting, and why is it necessary in modern operating systems?

Easy Answer: File system mounting is the process by which an operating system makes a secondary storage device (such as a USB flash drive, external hard disk, CD-ROM, or a network share) accessible to users through the computer's main directory tree.

How it Works: Before a storage device can be used, its root file system must be "attached" (mounted) to a specific directory (called a mount point) within the existing directory structure of the operating system.

Why It Is Necessary:

  • Unified Namespace: Modern OS architectures maintain a single, seamless directory tree. Mounting allows separate physical devices to appear as folders inside this single tree rather than requiring separate drive letters or confusing connection portals for every device.
  • Hardware Independence: It abstracts hardware details. Whether a file is stored on an internal NVMe SSD, an external USB stick, or a server across the internet, the OS handles them uniformly once mounted.
  • Security and Control: Mounting allows the OS to apply specific permissions, read-only flags, and caching policies to a storage device upon connection.

Example: In Linux, when you plug in a USB drive, the OS automatically mounts it to a directory like /media/usb-drive. You can then access its files as if they were standard folders inside your computer.

Q: Describe the three main file allocation methods: contiguous, linked, and indexed.

Easy Answer: File allocation methods determine how the operating system stores file blocks on a disk. The three primary methods are:

  • 1. Contiguous Allocation:
    • Mechanism: Each file occupies a set of contiguous (consecutive) blocks on the disk. The directory entry stores only the starting block address and the length of the file.
    • Pros & Cons: Excellent performance for sequential and direct access (very little head movement). However, it suffers severely from external fragmentation and makes file growth difficult if adjacent space is occupied.
  • 2. Linked Allocation:
    • Mechanism: Each file is stored as a linked list of disk blocks, which can be scattered anywhere on the disk. Each block contains a pointer to the next block. The directory stores pointers to the first and last blocks.
    • Pros & Cons: Eliminates external fragmentation and makes file growth effortless (no size estimation needed). However, it only supports sequential access efficiently, and if a single pointer block is damaged, the rest of the file is lost.
  • 3. Indexed Allocation:
    • Mechanism: Solves the limitations of both methods by bringing all pointers together into one location called an index block. Each file has its own index block, where the $i$-th entry points to the $i$-th data block of the file.
    • Pros & Cons: Supports efficient direct access without external fragmentation. However, it can waste storage space for small files (since every file needs an index block) and requires multi-level indexing for very large files.

Example: Contiguous is like parking cars in a straight row; linked is like a treasure hunt where each clue points to the next location; indexed is like an index page in a textbook telling you exactly which page number to turn to.

Q: How does bit vector representation assist in free-space management?

Easy Answer: Free-space management is the technique used by the operating system to keep track of available (unallocated) disk blocks so that new files can be stored or existing files can expand. One of the most popular methods for free-space management is the bit vector (or bitmap).

  • How Bit Vector Works: The disk space is represented as a series of bits, where each bit corresponds to a single disk block.
    • A bit value of 1 indicates that the block is free.
    • A bit value of 0 indicates that the block is allocated (occupied).
  • Example Map: 110011100... means block 0 and 1 are free, 2 and 3 are allocated, 4, 5, and 6 are free, and so on.
  • How the OS Uses It: When the OS needs to allocate $N$ blocks for a new file, it scans the bit vector sequentially to find the first sequence of '1's. Once found, it marks them as '0's (allocated). When files are deleted, their corresponding bits are flipped back to '1'.

Advantages:

  • It is simple and easy to implement.
  • It is extremely efficient for finding contiguous blocks of free space on the disk using fast bitwise operations (like finding the first non-zero bit in a word).

Q: Define a file from the operating system's perspective.

Easy Answer: From an operating system's perspective, a file is a logical unit of related information recorded on secondary storage, abstracted as a uniform sequence of bytes or records. The OS hides the complex hardware details of physical storage (sectors, tracks, and heads) and presents files as logical entities that applications can easily create, read, write, and delete using system calls.

Q: What is the difference between file access permissions and file protection?

Easy Answer: File access permissions specify the specific operations a user or group can perform on a file, typically divided into Read (R), Write (W), and Execute (X) rights. File protection is the broader security mechanism and policy framework implemented by the operating system to enforce these permissions, ensuring that unauthorized users cannot access, modify, or destroy sensitive data.

Q: Explain the role of a directory in an operating system.

Easy Answer: A directory acts as a symbol table or organizational map for the file system. Its primary role is to map human-readable file names to their corresponding File Control Blocks (FCBs) or internal disk locations. Directories allow users and the operating system to group, locate, traverse, and manage files efficiently in a hierarchical structure.

Q: What is a file control block (FCB)?

Easy Answer: A File Control Block (FCB) is a storage structure maintained by the operating system that contains all the metadata and attributes of a specific file. This includes the file's ownership, access permissions, physical location on disk, size, and creation/modification timestamps. In UNIX systems, the FCB is referred to as an inode.

Q: Briefly define contiguous allocation and its main drawback.

Easy Answer: Contiguous allocation is a file storage method where each file occupies a continuous, unbroken sequence of disk blocks. The main drawback of this method is external fragmentation, which occurs as files are created and deleted over time, leaving scattered free blocks that are too small to be useful, making it difficult to store large new files.

Q: What are the advantages of linked allocation over contiguous allocation?

Easy Answer: The primary advantages of linked allocation over contiguous allocation are that it completely eliminates external fragmentation (since any free block anywhere on the disk can be used) and it makes file growth effortless. Files can expand dynamically without needing to pre-allocate space or undergo costly defragmentation.

Q: Explain what an index block is in the context of indexed allocation.

Easy Answer: In indexed allocation, an index block is a dedicated disk block that contains an array of pointers (disk addresses) to all the other blocks that make up a specific file. Instead of scattering pointers inside data blocks (like linked allocation), all pointers are gathered in one central index block, enabling fast direct access.

Q: What is free-space management?

Easy Answer: Free-space management is the method by which an operating system tracks all unallocated (free) blocks on a storage device. This allows the OS to quickly locate and assign available disk blocks when new files are created or existing files are expanded. Common techniques include bit vectors, linked lists, and grouping.

Q: List two common disk scheduling algorithms.

Easy Answer: Two common disk scheduling algorithms used by operating systems to optimize the movement of the disk read/write head are:
1. FCFS (First-Come, First-Served): Requests are serviced in the exact order they arrive.
2. SCAN (Elevator Algorithm): The disk arm moves in one direction servicing requests until it reaches the end, then reverses direction.

Q: Why is seek time a critical factor in disk I/O performance?

Easy Answer: Seek time is the time required for the disk arm to move the read/write heads to the specific cylinder containing the desired track. Because mechanical head movement involves physical inertia and hardware latency, it is the slowest operation in disk I/O. Minimizing seek time is critical for maximizing overall system speed and throughput.

Part 3: Detailed Exam Long Questions (20-Marks Standard)

Long Question: Discuss the detailed architecture of file systems, focusing on file operations, file attributes, and different file access methods used by operating systems.

Welcome to Unit 6 of Introduction to Computing (Course 3400). In modern computing, managing vast amounts of data efficiently is one of the most critical roles of an Operating System (OS). A file system acts as the structural foundation that organizes, stores, retrieves, and protects data on storage devices such as hard disk drives (HDDs), solid-state drives (SSDs), and USB flash drives. Without a file system, a storage device would simply be an endless, unorganized sea of binary data (ones and zeros), making it impossible for users to find or manage their documents, pictures, and applications. Understanding file system architecture—specifically how files are defined, what metadata they hold, the operations performed on them, and how applications access them—is essential for grasping computer science fundamentals. This comprehensive exam answer explores the detailed architecture of file systems in simple, student-friendly terms.

1. Conceptual Definition of a File and File System

At its core, a file is a collection of related information or data recorded on secondary storage. The operating system abstracts the physical properties of the storage device, presenting files as logical, continuous streams of bytes. A file system is the logical method and data structure that an OS uses to control how data is stored and retrieved. Think of a physical library: books represent files, shelves represent directories, and the library cataloging system represents the file system.

2. Detailed Breakdown of File Attributes (Metadata)

Every file in a modern operating system possesses metadata, which are characteristics or attributes that describe the file without containing its actual content. Common file attributes include:

  • Name: The human-readable identifier (e.g., "homework.docx").
  • Identifier: A unique tag, usually a number, that identifies the file within the file system structure.
  • Type: Information indicating the format of the file (e.g., PDF, JPEG, EXE), often denoted by an extension.
  • Location: A pointer to the exact device and physical address where the file is stored on the disk.
  • Size: The current byte-size of the file, sometimes including maximum allowable size.
  • Protection/Permissions: Rules specifying who can read, write, or execute the file.
  • Time, Date, and User Identification: Timestamps for creation, last modification, and last access, crucial for security and auditing.

3. Core File Operations Supported by the Operating System

The operating system provides system calls that allow users and applications to interact with files. The six primary file operations are:

  • Creating a File: Finding space on the storage device and allocating a directory entry for the new file.
  • Writing a File: Adding data to the file at the current write pointer position.
  • Reading a File: Retrieving data from the file starting from the current read pointer position.
  • Repositioning within a File (Seeking): Moving the file pointer to a specific location within the file without reading or writing data.
  • Deleting a File: Removing the file's content and freeing up its allocated storage space and directory entry.
  • Truncating a File: Erasing the file's content while keeping its attributes and resetting its length to zero.

4. File System Architecture Layers

File systems are structured in layers to separate concerns and modularize code. The bottom layers deal with physical hardware and device drivers, while the top layers interact directly with user applications. These layers include the logical file system, file organization module, basic file system, I/O control, and devices. This layered approach ensures that changing a physical hard disk does not require rewriting the entire operating system.

5. Sequential Access Method

Sequential access is the simplest and most traditional method of accessing file data. In this method, information in the file is processed in order, one record after the other. If a program wants to read record number 50, it must first read records 1 through 49. Magnetic tapes are classic examples of sequential access devices. In modern computing, text files and log files are frequently read sequentially.

6. Direct (Random) Access Method

Direct access (or random access) allows a program to read or write data anywhere in the file rapidly without reading the preceding bytes. The file is viewed as a numbered sequence of blocks or records. For example, a database management system uses direct access to jump straight to customer record #500,000 in milliseconds. Hard drives and SSDs natively support direct access because their read/write heads or flash memory cells can target specific physical addresses instantly.

7. Indexed Access Method

Indexed access is an advanced method built on top of direct access. When files are large and direct access becomes cumbersome, the file system creates an index—similar to the back index of a textbook. To find a specific record, the OS first searches the small index file, which points directly to the exact disk block containing the desired data. This method balances flexibility and search speed.

8. Directory Structures and Hierarchical Organization

Files are organized using directories (or folders). Modern operating systems use a tree-structured (hierarchical) directory system. Users can create subdirectories within directories, creating a logical path (e.g., `C:\Documents\School\Exam.pdf`). This hierarchical design prevents naming conflicts, as two different folders can contain a file named `notes.txt` without any overlap.

9. File Sharing and Protection Mechanisms

In multi-user operating systems (like Linux or Windows Server), file systems must support file sharing while maintaining strict security. Access control lists (ACLs) and permission matrices (Read, Write, Execute) dictate which users or groups can access specific files. Symbolic links and hard links allow multiple users or directories to reference the exact same underlying file safely.

10. Real-World Exam Summary and Conclusion

In summary, the file system architecture is the vital bridge between human-readable data concepts and physical hardware storage. By managing comprehensive file attributes, executing robust system operations, and offering versatile access methods (sequential, direct, and indexed), the operating system ensures data is secure, organized, and quickly accessible. Mastery of these concepts is fundamental for IT professionals and computer scientists alike.

Long Question: Compare and contrast the three primary disk space allocation methods (Contiguous, Linked, and Indexed) in detail, highlighting the pros and cons of each regarding fragmentation and direct access.

Disk space allocation methods determine how the operating system stores file data blocks on secondary storage devices like hard disks. Because secondary storage is limited and divided into fixed-size blocks (typically 512 bytes to 4KB), the OS must manage these blocks efficiently to maximize storage capacity and retrieval speed. When a user creates or expands a file, the file system must allocate free disk blocks to accommodate the data. The three primary allocation methods used throughout computing history are Contiguous Allocation, Linked Allocation, and Indexed Allocation. Each method offers unique trade-offs regarding storage utilization, external fragmentation, directory overhead, and support for direct (random) access. This detailed exam-standard analysis compares and contrasts these three techniques.

1. Introduction to Disk Space Allocation

Disk space allocation refers to the strategy employed by the operating system to map logical file blocks onto physical disk blocks. The primary goals of any allocation method are efficient utilization of disk space and fast access to file data. However, these goals often conflict; optimizing for speed can waste space, while maximizing space can slow down access times.

2. Contiguous Allocation: Definition and Mechanism

In contiguous allocation, each file occupies a single, continuous set of blocks on the disk. For example, if a file requires 4 blocks and starts at block 50, it occupies blocks 50, 51, 52, and 53 consecutively. The directory entry for the file stores only two pieces of information: the address of the starting block and the total length (number of blocks) of the file.

3. Pros and Cons of Contiguous Allocation

Pros: Contiguous allocation offers phenomenal performance for direct access. Because blocks are consecutive, calculating the physical address of any block is simple arithmetic (Starting Address + Offset). Furthermore, reading an entire file requires minimal head movement (seek time).
Cons: The major drawback is External Fragmentation. As files are created, deleted, and resized over time, the free disk space breaks into small, scattered pockets. A file cannot grow if there is no contiguous block large enough, forcing expensive disk compaction processes.

4. Linked Allocation: Definition and Mechanism

Linked allocation solves the fragmentation problem of contiguous allocation by storing files as a linked list of disk blocks. The blocks do not need to be contiguous. Each file is a discrete list of pointers to disk blocks. The directory entry contains a pointer to the first disk block and the last disk block. Each block itself contains a pointer pointing to the next block in the file.

5. Pros and Cons of Linked Allocation

Pros: There is zero external fragmentation. Any free block on the disk can be added to a file's chain. Files can easily grow dynamically without needing compaction.
Cons: Linked allocation has severe drawbacks. First, it does not support efficient direct access; to read block #100, the OS must read blocks 1 through 99 sequentially to follow the pointers. Second, pointer overhead wastes storage space (e.g., 4 bytes out of a 512-byte block). Third, if a single pointer is corrupted or lost due to a bad sector, the rest of the file becomes unreadable.

6. File Allocation Table (FAT) Variant

A notable variation of linked allocation is the File Allocation Table (FAT) used in older Microsoft operating systems (FAT16, FAT32). Instead of storing pointers inside the data blocks, a dedicated table at the beginning of the volume holds all the block links. This allows the OS to traverse the chain quickly in memory without reading every physical data block, improving direct access efficiency.

7. Indexed Allocation: Definition and Mechanism

Indexed allocation solves the direct access limitations of linked allocation by bringing all the pointers together into one central location called the index block. Each file has its own index block, which is an array of disk block addresses. The directory entry contains the address of the file's index block. The $i$-th entry in the index block points to the $i$-th data block of the file.

8. Pros and Cons of Indexed Allocation

Pros: Indexed allocation supports direct access efficiently without external fragmentation. To access block #50 of a file, the OS simply looks at the 50th entry in the index block, exactly like looking up an array in programming.
Cons: The main disadvantage is pointer overhead. For a very small file that only takes one data block, wasting an entire block for an index table is inefficient. For extremely large files, a single index block may not hold all pointers, requiring complex multi-level index schemes (like Unix inode structures).

9. Comparative Analysis: Fragmentation & Direct Access

Allocation Method External Fragmentation Direct Access Support Space Overhead
Contiguous High (Requires compaction) Excellent (Fastest) None
Linked None Poor (Sequential traversal required) High (Pointers inside blocks)
Indexed None Excellent (Direct lookup) Moderate (Index blocks needed)

10. Summary and Exam Conclusion

In conclusion, choosing a disk space allocation method is a classic engineering compromise. Contiguous allocation delivers blazing speed for direct access but suffers from severe external fragmentation. Linked allocation eliminates fragmentation entirely but cripples direct access and risks data loss upon pointer corruption. Indexed allocation strikes an optimal balance by supporting direct access and avoiding fragmentation through dedicated index blocks, making it the architectural basis for many modern file systems (such as ext4 and NTFS variants).

Long Question: Explain the various disk scheduling algorithms (FCFS, SSTF, SCAN, C-SCAN) with illustrative examples, and analyze their efficiency in minimizing head movement.

In computer operating systems, secondary storage devices such as magnetic hard disk drives (HDDs) consist of spinning platters and a mechanical read/write head mounted on a movable arm. When multiple processes request read and write operations concurrently, the operating system queues these requests. Because mechanical movement (moving the disk arm and waiting for the platter to rotate) is thousands of times slower than electronic memory access, the order in which disk requests are serviced drastically impacts overall system performance. Disk scheduling algorithms are strategies used by the operating system to determine the servicing order of pending I/O requests with the primary goal of minimizing mechanical head movement, reducing seek time, and maximizing throughput. This comprehensive exam-standard answer examines the four primary disk scheduling algorithms.

1. Fundamentals of Disk I/O Performance

Disk access time is divided into seek time and rotational latency. Seek time—the time required to move the disk arm to the desired cylinder track—is the most time-consuming component. Disk scheduling algorithms specifically target seek time reduction. To understand these algorithms, assume a standard disk with cylinders numbered from $0$ to $199$, and a disk request queue arriving in a specific sequence.

2. First-Come, First-Served (FCFS) Scheduling

FCFS is the simplest disk scheduling algorithm. Requests are serviced strictly in the order they arrive in the I/O queue, with no regard for the current position of the disk head.
*Example:* If the head is currently at cylinder $50$, and the queue is `[98, 183, 37, 122, 14, 124, 65, 67]`, the head moves from $50 \rightarrow 98 \rightarrow 183 \rightarrow 37 \rightarrow 122 \rightarrow 14 \rightarrow 124 \rightarrow 65 \rightarrow 67$.
*Analysis:* While fair and easy to implement, FCFS performs poorly in minimizing head movement because it often causes wild, inefficient swings back and forth across the entire disk surface, resulting in long total seek times.

3. Shortest Seek Time First (SSTF) Scheduling

SSTF selects the request from the queue that is closest (has the minimum seek distance) to the current head position. It is a form of greedy algorithm.
*Example:* With the head at $50$ and queue `[98, 183, 37, 122, 14, 124, 65, 67]`, the head services $37$ (distance 13), then $14$ (distance 23), then reverses to $65$ (distance 51), then $67$, $98$, $122$, $124$, and finally $183$.
*Analysis:* SSTF significantly reduces total head movement compared to FCFS and improves overall throughput. However, it suffers from a major flaw: starvation. Requests located far away from active head clusters can be indefinitely delayed if a steady stream of close requests continues to arrive.

4. SCAN (Elevator) Algorithm

To prevent the starvation problem of SSTF, the SCAN algorithm behaves like an elevator in a building. The disk head starts at one end of the disk and moves toward the other end, servicing all requests in its path until it reaches the final cylinder. Once it hits the end, the direction reverses, and it services requests on the return trip.
*Example:* Assuming the head is at $50$ moving towards higher cylinders (e.g., 199), it services $65, 67, 98, 122, 124, 183$, hits the edge at $199$, reverses direction, and services remaining requests $37$ and $14$ on the way down.
*Analysis:* SCAN provides much fairer service than SSTF and eliminates starvation. However, wait times can be uneven; requests just passed by the moving head must wait for the head to reach the end of the disk, reverse, and travel all the way back.

5. Circular SCAN (C-SCAN) Algorithm

C-SCAN is a modified version of SCAN designed to provide a more uniform wait time. Instead of reversing direction at the end of the disk, the disk head moves in only one direction. When the head reaches the highest cylinder, it immediately returns to cylinder $0$ without servicing any requests on the return trip, and then resumes its forward sweep.
*Example:* Moving upward from $50$, the head services $65, 67, 98, 122, 124, 183, 199$. Upon reaching $199$, it jumps instantly back to cylinder $0$ and sweeps upward to service $14$ and $37$.
*Analysis:* C-SCAN treats cylinders as a circular list that wraps around from the final cylinder to the first. This creates a uniform waiting time across all cylinders, preventing the bias inherent in regular SCAN where middle cylinders are serviced twice as often as edge cylinders.

6. Comparative Efficiency and Quantitative Analysis

Algorithm Total Head Movement (Example) Starvation Risk Fairness
FCFS Very High (~640 cylinders) None High (Strictly fair)
SSTF Low (~236 cylinders) High (Starvation possible) Low
SCAN Moderate (~208 cylinders) None Moderate
C-SCAN Higher than SCAN due to jump None High (Uniform wait time)

7. Other Advanced Algorithms (LOOK and C-LOOK)

Variants like LOOK and C-LOOK improve upon SCAN and C-SCAN by avoiding unnecessary travel to the absolute physical edges of the disk ($0$ and $199$). In LOOK, the head only travels as far as the last actual request in that direction before reversing, further optimizing seek time and efficiency.

8. Impact of Modern SSDs on Disk Scheduling

It is important to note that mechanical disk scheduling algorithms were designed for HDDs with moving parts. Solid-State Drives (SSDs) have no moving heads or platters; data access time is uniform regardless of physical location. Therefore, operating systems treat SSD I/O queues differently, often using simple asynchronous queue management rather than traditional seek-optimizing algorithms.

9. Summary and Exam Conclusion

In conclusion, disk scheduling algorithms are vital operating system tools for optimizing mechanical disk I/O performance. While FCFS is straightforward but inefficient, SSTF minimizes seek time at the risk of starvation. Algorithms like SCAN and C-SCAN successfully balance throughput, head movement reduction, and fairness, ensuring reliable system performance in multi-tasking environments.

Long Question: Examine free-space management techniques in file systems, specifically discussing bit vectors, linked lists, grouping, and counting methods.

Storage management is a core responsibility of any operating system. Because secondary storage capacity is finite, the file system must meticulously track which disk blocks are currently allocated to files and which blocks are vacant and available for future use. This bookkeeping mechanism is known as free-space management. Whenever a new file is created or an existing file is expanded, the operating system consults its free-space list to allocate vacant blocks. Conversely, when files are deleted, their blocks are returned to the free-space pool. If free-space management fails or becomes corrupted, data loss or storage leaks can occur. This comprehensive exam-standard answer examines the four primary techniques used by operating systems to manage free disk space: Bit Vectors, Linked Lists, Grouping, and Counting.

1. Introduction to Free-Space Management

Free-space management ensures that the operating system always knows the exact state of every block on a storage volume. To keep track of free blocks without scanning the entire disk every time space is needed, the file system maintains a dedicated data structure called the free-space list or free-space map. While called a "list," it is rarely implemented as a simple linear list due to performance considerations.

2. Bit Vector (Bitmap) Technique

The bit vector (or bitmap) method represents free space using an array of bits where each bit corresponds to a specific disk block. If a block is free, its bit is set to $1$; if it is allocated, its bit is set to $0$.
*Example:* A disk with 4,096 blocks requires a bitmap of 4,096 bits (which is only 512 bytes). Block 0 corresponds to bit 0, block 1 to bit 1, and so on.
*Pros & Cons:* The primary advantage of a bitmap is its simplicity and efficiency in finding contiguous blocks of free space (using bitwise logical operations like `AND`, `OR`, and `NOT`). The main disadvantage is that the entire bitmap must be kept in main memory (RAM) for fast performance; on massive modern terabyte drives, bitmap size can become substantial, though still manageable.

3. Linked List Technique

In the linked list free-space management method, all free disk blocks are linked together in a chain. The file system pointer keeps track of the address of the first free disk block. That first free block contains a pointer pointing to the second free block, and so on, until the end of the chain.
*Pros & Cons:* This method is space-efficient because it does not require a separate large table or bitmap; it utilizes the vacant blocks themselves to store pointers. However, traversal is extremely slow. To find $n$ free blocks, the OS must read multiple blocks sequentially, making allocation inefficient.

4. Grouping Technique

The grouping method is a clever modification of the linked list approach designed to improve allocation speed. Instead of linking single free blocks one by one, the first free block in a chain stores the addresses of $n$ additional free blocks. Out of those $n$ blocks, the first $n-1$ blocks are genuinely free data blocks, while the last block contains the addresses of the *next* group of free blocks.
*Pros & Cons:* Grouping drastically reduces the time required to find multiple free blocks compared to a standard linked list, because a single block read reveals the addresses of many subsequent free blocks instantly. However, it still requires pointer maintenance overhead.

5. Counting Technique

The counting method is based on the observation that space is frequently allocated and freed in contiguous chunks (multiple contiguous blocks at a time). Instead of listing every single free block individually, the file system keeps track of the address of the first free block and the *number* of contiguous free blocks that follow it (the "count").
*Example:* Instead of listing blocks 100, 101, 102, 103, and 104 individually, the free-space table stores an entry stating: `Starting Address = 100, Count = 5`.
*Pros & Cons:* This method makes the free-space list extremely compact, especially in file systems that favor contiguous allocation. However, managing the table can become complex as files are constantly created, deleted, and fragmented.

6. Comparative Efficiency of Free-Space Techniques

Technique Memory Overhead Speed of Finding Free Blocks Best Suited For
Bit Vector Low to Moderate (requires RAM) Very Fast (Bitwise operations) General-purpose file systems
Linked List Very Low Slow (Sequential traversal) Simple embedded systems
Grouping Low Moderate to Fast Systems needing quick multi-block allocation
Counting Low (compact entries) Fast for contiguous blocks Contiguous allocation environments

7. Integration with File Allocation Structures

Free-space management does not operate in a vacuum; it interacts closely with the file system's allocation tables (like inodes, FAT, or ext4 block groups). When a user deletes a file, the OS marks its corresponding inodes or directory entries as inactive and updates the free-space manager (such as setting bits back to $1$ in the bitmap) so that the space can be safely overwritten.

8. Consistency Checking and File System Recovery

Because free-space maps and allocation tables are constantly modified in RAM and flushed to disk periodically, system crashes (like sudden power outages) can cause discrepancies. Utilities like `fsck` (File System Consistency Check) or `chkdsk` in Windows scan the storage device to cross-reference allocated blocks with the free-space list, ensuring no blocks are mistakenly marked as both allocated and free (double allocation).

9. Summary and Exam Conclusion

In summary, effective free-space management is vital for the health and performance of any computer file system. Whether utilizing the direct bitwise clarity of Bit Vectors, the space-saving nature of Linked Lists, the batch-processing speed of Grouping, or the compact efficiency of Counting methods, operating systems must balance memory overhead against allocation speed to ensure seamless data storage operations.

Part 4: Solved Multiple Choice Questions (MCQs)

MCQ #1 What is a collection of related information recorded on secondary storage called?

Folder
File
Directory
Sector

MCQ #2 Which of the following is typically NOT considered a file attribute?

File name
File size
File color
File protection

MCQ #3 Which file access method reads records in order, one after the other?

Direct access
Sequential access
Indexed access
Random access

MCQ #4 Which file allocation method requires each file to occupy a set of contiguous blocks on the disk?

Linked allocation
Indexed allocation
Contiguous allocation
Pointer allocation

MCQ #5 Which allocation method solves external fragmentation by linking disk blocks via pointers?

Contiguous allocation
Linked allocation
Sequential allocation
Direct allocation

MCQ #6 Which structure brings together all the pointers to a file's blocks into a single block?

Index block
Link block
Contiguous block
FAT block

MCQ #7 Before a file system can be used by the operating system, what must be done to it?

Formatted
Mounted
Encrypted
Compressed

MCQ #8 Which free-space management technique uses a bit map or bit vector?

Linked list
Grouping
Bit vector
Counting

MCQ #9 Which disk scheduling algorithm moves the disk arm in one direction to the end, then reverses?

FCFS
SCAN
SSTF
FIFO

MCQ #10 Which disk scheduling algorithm minimizes head movement by always choosing the request closest to the current head position?

FCFS
SSTF
SCAN
C-LOOK

MCQ #11 What is the simplest and most primitive disk scheduling algorithm?

FCFS
SSTF
SCAN
LOOK

MCQ #12 What is the primary purpose of access control lists (ACL) in file systems?

Speed up file access
Provide file protection and security
Manage free disk space
Organize directories

MCQ #13 What does a directory structure store for each file it contains?

File data
File attributes and pointers
Only file size
Only file creation time

MCQ #14 Which disk scheduling algorithm treats cylinders as a circular list that moves in only one direction?

SCAN
C-SCAN
SSTF
FCFS

MCQ #15 Which free-space management method links free blocks together, keeping a pointer to the first free block?

Bit vector
Linked list
Contiguous list
Index table

Manage Cookie Preferences

Strictly Necessary Cookies

Required for consent storage and site security.

Always Active

View full details in our Cookies Policy & Privacy Policy.