I/O SYSTEMS, FILE &
DISK MANAGEMENT
Study Guide
Bela Shah
CSE, PIT
Parul University
Table of Contents
6.1 I/O Hardware ......................................................................................................................................................... 2
6.2 Direct Memory Access (DMA) ................................................................................................................................ 3
6.3 Device Drivers ........................................................................................................................................................ 4
6.4 File Management ................................................................................................................................................... 5
6.5 Allocation Methods................................................................................................................................................ 6
6.6 Directory Implementation ..................................................................................................................................... 7
6.7 Disk Management .................................................................................................................................................. 8
6.8 Disk Reliability ...................................................................................................................................................... 12
6.9 Disk Formatting, Boot Block, Bad Blocks ............................................................................................................. 12
6.10 Key Takeaways ................................................................................................................................................... 13
6.11 References ......................................................................................................................................................... 15
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 1
6.1 I/O Hardware
I/O devices are hardware components that allow communication between the computer system and
the external world. They can be classified as:
1. Input Devices
• Keyboard, mouse, scanner, microphone, barcode reader.
• Convert user actions or physical data into machine-readable signals.
2. Output Devices
• Monitor, printer, speaker, projector.
• Convert digital information into human-understandable form.
3. Storage Devices
• HDD, SSD, USB drive, CD/DVD.
• Used for long-term data storage.
4. Communication Devices
• Network Interface Cards (NIC), modem, Wi-Fi adapters.
• Enable data transfer between computers.
Device Characteristics
• Transfer rate (speed of data transfer)
• Data format: character vs. block devices
• Access method: random vs. sequential
• Latency & bandwidth
Device Controllers
A device controller is hardware that manages communication between the CPU and an I/O device.
Components of Device Controller
• Data Register: Stores data being transferred.
• Status Register: Indicates device state (busy, ready, error).
• Control Register: Used by CPU to send commands to device.
Communication Techniques
1. Polling: CPU repeatedly checks device status.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 2
2. Interrupts: Device notifies CPU when ready.
3. DMA: Device communicates directly with memory.
6.2 Direct Memory Access (DMA)
(DMA) DMA enables devices to transfer data directly to main memory without continuous CPU
involvement.
Why DMA?
• Reduces CPU overhead.
• Speeds up data transfer.
DMA Operation Steps
1. CPU programs DMA controller with source, destination, and size.
2. DMA controller requests bus control from CPU.
3. DMA transfers data directly to memory.
4. DMA sends an interrupt to CPU after completion.
DMA Transfer Modes
• Burst mode: DMA transfers entire block at once.
• Cycle stealing: DMA takes bus for one cycle and releases.
• Transparent mode: DMA works only when CPU is idle.
Principles of I/O Software
I/O software is organized in layers for better modularity and portability.
Goals of I/O Software
• Device independence.
• Uniform naming.
• Error handling.
• Buffering and caching.
• Security and protection.
Layers of I/O Software
1. Interrupt Handlers
2. Device Drivers
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 3
3. Device-Independent I/O Software
4. User-level I/O Libraries
Goals of Interrupt Handlers
• Respond quickly to interrupts.
• Save CPU context.
• Identify interrupt source.
• Wake up waiting processes.
• Restore system state.
6.3 Device Drivers
Device drivers are software modules that handle device-specific operations.
Responsibilities of Device Drivers
• Translate OS commands to device commands.
• Manage buffering and data format conversion.
• Handle device initialization and shutdown.
• Provide interrupt service routines.
• Handle device-specific errors.
Types of Drivers
• Character device drivers (keyboard, mouse)
• Block device drivers (disk, USB drive)
• Network drivers (NIC)
Device-Independent I/O Software
This layer provides functionalities common to all devices.
Functions Include:
• Naming and protection.
• Buffering and spooling.
• Error detection and reporting.
• Caching.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 4
• File system support.
6.4 File Management
Concept of File
A file is a named collection of related information stored on secondary storage. - Has attributes like
name, type, permission, size, timestamps.
Access Methods
1. Sequential Access
• Processes data in order.
• Suitable for magnetic tapes.
2. Direct (Random) Access
• Access any block directly.
• Suitable for disks.
3. Indexed Access
• Uses index table to locate blocks.
File Types
• Text files
• Binary files
• Executable files
• Multimedia files
File Operations
• Create, open, close
• Read, write
• Reposition (seek)
• Delete, truncate
• Change file attributes
Directory Structure
• Single-level directory
• Two-level directory
• Tree structure (most common)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 5
• Acyclic graph (allows shared files)
• General graph directory (requires cycle detection)
File System Structure (Layers)
1. Application programs
2. Logical file system
3. File-organization module
4. Basic file system
5. I/O control layer
6. Device drivers
6.5 Allocation Methods
Example: Contiguous Allocation
File A occupies blocks: 10, 11, 12, 13, 14
Diagram:
+----+----+----+----+----+----+
| 10 | 11 | 12 | 13 | 14 | 15 |
+----+----+----+----+----+----+
|<--- File A ---->| Free Block |
Example: Linked Allocation
File B: 7 → 23 → 14 → 9
Diagram:
+----+ +----+ +----+ +----+
| 7 | --> | 23 | --> | 14 | --> | 9 |
+----+ +----+ +----+ +----+
Example: Indexed Allocation
Index Block = 5
File blocks = [20, 7, 15, 9]
Diagram:
+---------+
| Index 5 |
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 6
+---------+
/ | | \
+----+ +----+ +----+ +----+
| 20 | | 7 | | 15 | | 9 |
+----+ +----+ +----+ +----+
Contiguous Allocation
• Files occupy consecutive disk blocks.
• Advantages: Fast random access.
• Disadvantages: External fragmentation, difficult file growth.
Linked Allocation
• Each block contains pointer to next.
• Advantages: No fragmentation.
• Disadvantages: Slow random access.
Indexed Allocation
• Uses index block pointing to file blocks.
• Advantages: Fast direct access.
• Disadvantages: Index block overhead.
Free-Space Management
1. Bit Vector
• 1 indicates free block; 0 indicates allocated.
• Simple and efficient.
2. Linked List
• Free blocks linked together.
3. Grouping
• Free blocks stored in groups for faster access.
6.6 Directory Implementation
Linear List
• Directory is a list of file names with attributes.
• Simple but slow for large directories.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 7
Hash Table
• Hash function maps file name to table index.
• Faster search, fewer comparisons.
Efficiency and Performance
• Hashing improves lookup.
• Caching frequently used folders speeds access.
• SSDs reduce seek time compared to HDDs.
6.7 Disk Management
Disk Structure
A magnetic disk is made of several physical parts:
Components
• Platter – circular disk coated with magnetic material.
• Tracks – concentric circles on the platter.
• Sectors – small wedge-shaped divisions of each track.
• Cylinders – group of tracks vertically across platters.
• Disk Arm + Head – moves to required track.
Disk Access Time
Disk access time =
✔ Seek Time (move head to track)
✔ Rotational Latency (wait for sector to rotate under head)
✔ Transfer Time
Scheduling algorithms focus on reducing seek time, the most expensive part.
Disk Scheduling Algorithms
2.1 FCFS (First Come First Serve)
Idea
Serve requests in the order they arrive.
Head Movement Sequence
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 8
53 → 98 → 183 → 37 → 122 → 14 → 124 → 65 → 67
Total Head Movement Calculation
Move Distance
53 → 98 45
98 → 183 85
183 → 37 146
37 → 122 85
122 → 14 108
14 → 124 110
124 → 65 59
65 → 67 2
Total Movement =
45 + 85 + 146 + 85 + 108 + 110 + 59 + 2 = 640 cylinders
Characteristics
✔ Simple
✔ Very inefficient
✔ Large variations in waiting time
SSTF (Shortest Seek Time First)
Idea
Choose the request closest to current head position → shortest seek.
Start: Head = 53
Closest request = 65 (distance 12)
Next closest = 67, then 37, etc.
Sequence
53 → 65 → 67 → 37 → 14 → 98 → 122 → 124 → 183
Total Movement
Move Distance
53 → 65 12
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 9
Move Distance
65 → 67 2
67 → 37 30
37 → 14 23
14 → 98 84
98 → 122 24
122 → 124 2
124 → 183 59
Total = 236 cylinders
Characteristics
✔ Much better than FCFS
✔ May cause starvation (far requests are never served)
SCAN (Elevator Algorithm)
Idea
Head moves in one direction (say upward → towards larger numbers):
→ serves all requests
→ reaches end
→ then reverses direction
Assume head moves upward from 53
Requests sorted:
14, 37, 65, 67, 98, 122, 124, 183
Upward movement sequence
53 → 65 → 67 → 98 → 122 → 124 → 183
At end, head reverses.
Then serve downward:
183 → 37 → 14
Total Movement
Upward:
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 10
Move Distance
53 → 183 130
Downward:
Move Distance
183 → 14 169
Total = 130 + 169 = 299 cylinders
Characteristics
✔ More fair
✔ No starvation
✔ Good overall performance
✔ Ends require extra travel
2.4 C-SCAN (Circular SCAN)
Idea
Like SCAN but head moves only in one direction.
After reaching end, the head jumps back to beginning without servicing requests.
Sequence (moving upward only)
53 → 65 → 67 → 98 → 122 → 124 → 183
Then jump to beginning (0)
Then serve lower ones:
0 → 14 → 37
Total Movement
Upward movement:
Move Distance
53 → 183 130
Jump (183 → 0):
Move Distance
183 → 0 183
Then:
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 11
Move Distance
0 → 37 → 14 37 + 23 = 60
Total = 130 + 183 + 60 = 373 cylinders
Characteristics
✔ More uniform wait times
✔ Ideal for heavy-load servers
✔ Slightly more movement than SCAN
Summary Table
Algorithm Total Head Movement Notes
FCFS 640 Very bad performance
SSTF 236 Best performance but may starve
SCAN 299 Fair, good average performance
C-SCAN 373 Uniform waiting time
6.8 Disk Reliability
Example: RAID 1 (Mirroring)
Disk A: [Data]
Disk B: [Data]
If Disk A fails → Disk B continues working.
Methods to Improve Reliability
• RAID levels (mirroring, parity).
• Bad block mapping.
• ECC (Error-Correcting Codes).
• Regular backups.
• SMART monitoring.
6.9 Disk Formatting, Boot Block, Bad Blocks
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 12
Example: Bad Block Mapping
Bad block found at: 2501
Remapped to spare block: 9001
Disk Formatting
Low-Level Formatting
• Divides disk into tracks and sectors.
• Performed by manufacturer.
Logical Formatting
• Creates file system structures (FAT, NTFS, EXT etc.).
Boot Block
• Contains code to load operating system.
• Usually stored in Master Boot Record (MBR) or GPT.
Bad Blocks
• Sectors that are damaged or unreadable.
Handling Techniques
• Sector sparing (remapping to spare sectors).
• Sector slipping.
• Marking blocks as unusable so OS avoids them.
6.10 Key Takeaways
I/O Hardware & Controllers
• I/O devices are categorized into input, output, storage, and communication devices.
• Device controllers act as an interface between hardware and CPU and use registers to manage data
transfer.
• Communication occurs through polling, interrupts, or DMA.
DMA (Direct Memory Access)
• DMA allows devices to transfer data directly to/from main memory without CPU involvement.
• Improves system efficiency, reduces overhead, and supports high-speed data transfer.
• Modes include burst, cycle-stealing, and transparent DMA.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 13
I/O Software & Interrupt Handlers
• I/O software is layered for modularity: interrupt handlers → drivers → device-independent I/O → user-
level libraries.
• Interrupt handlers ensure fast response, save system state, and resume processes efficiently.
Device Drivers
• Provide device-specific control and translate OS-level commands into device actions.
• Handle initialization, error management, buffering, and formatting of data.
File Management
• A file is a logical data container with attributes like name, type, and permissions.
• Access methods: sequential, direct/random, and indexed.
• Directory structures vary from simple (single-level) to complex (tree, acyclic graph).
• File systems have layered organization for efficient management.
Allocation Methods
• Contiguous allocation offers fast access but suffers from fragmentation.
• Linked allocation removes fragmentation but slows random access.
• Indexed allocation provides direct access but needs index blocks.
• Free-space management uses bitmaps, linked lists, or grouping.
Directory Implementation & Efficiency
• Implemented via linear list or hash tables.
• Hash tables improve access speed significantly.
• Efficiency depends on caching, lookup method, and disk technology.
Disk Structure
• A disk contains platters, tracks, sectors, cylinders, and mechanical arms.
• Disk access time depends heavily on seek time, rotational latency, and transfer time.
Disk Scheduling Algorithms
• FCFS: simplest but inefficient with high head movement.
• SSTF: minimizes seek but can starve distant requests.
• SCAN: fair, moves like an elevator; reduces starvation.
• C-SCAN: uniform wait time, moves in one direction only.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 14
• Performance varies; SSTF is fastest, FCFS is worst.
Disk Reliability
• Enhancements include RAID, ECC, SMART monitoring, and backups.
• Mirroring (RAID 1) ensures data availability even if one disk fails.
Disk Formatting & Bad Blocks
• Low-level formatting creates sectors/tracks.
• Logical formatting creates file-system structures.
• Boot block contains OS loader.
• Bad blocks handled via sparing, slipping, or marking unusable.
6.11 References
Textbooks
1. Silberschatz, Abraham, Peter Baer Galvin, and Greg Gagne.
Operating System Concepts. 9th Edition, Wiley, 2018.
(Most widely used reference for I/O, DMA, File Systems, and Disk Scheduling)
2. Stallings, William.
Operating Systems: Internals and Design Principles. 8th Edition, Pearson, 2018.
(Detailed explanations of device management and disk scheduling)
3. Tanenbaum, Andrew S., and Herbert Bos.
Modern Operating Systems. 4th Edition, Pearson, 2015.
(Excellent for I/O software layers, drivers, file management, and DMA)
4. Dhamdhere, D. M.
Operating Systems: A Concept-Based Approach. 3rd Edition, McGraw-Hill.
(Popular Indian author; useful for exam-oriented topics)
Academic and Online Resources
1. MIT OpenCourseWare – Operating Systems
[Link]
(Free academic lectures and materials)
2. NPTEL Online Course – Operating Systems
[Link]
(Indian government-approved course; very relevant to your syllabus)
3. GeeksforGeeks – Operating Systems
[Link]
(Good for quick revision and examples like disk scheduling)
4. TutorialsPoint – Operating System
[Link]
(Basic explanations with diagrams)
Research Papers / Additional Reading
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 15
1. Peterson, L. L., & Silberschatz, A.
“Operating System Support for High-Speed Networking.” ACM Communications, 1991.
2. Ritchie, Dennis M., and Ken Thompson.
“The UNIX Time-Sharing System.” Bell System Technical Journal, 1974.
(Historical but foundational for file systems)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 16
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 1