I/O Management and Disk Scheduling
I/O Management is the function of the Operating System that controls and coordinates all input and output operations between the computer and external devices.
I/O Devices
I/O devices are hardware components that allow the system to communicate with the external world.
Classification of I/O Devices
| Type | Examples |
|---|
| Input Devices | Keyboard, Mouse, Scanner |
| Output Devices | Monitor, Printer |
| Storage Devices | Hard Disk, SSD |
| Communication Devices | Modem, Network Card |
Device Characteristics
| Characteristic | Description |
|---|
| Data Transfer Rate | Speed of data transfer |
| Unit of Transfer | Byte or block |
| Access Method | Sequential or random |
| I/O Control | Polling, Interrupts, DMA |
I/O Subsystems
I/O Subsystem is the OS layer that manages I/O devices efficiently and uniformly.
Functions of I/O Subsystem
| Function | Explanation |
|---|
| Device abstraction | Hides hardware details |
| Scheduling | Orders I/O requests |
| Buffering | Smooth data transfer |
| Error handling | Detects and handles errors |
| Device allocation | Assigns devices |
Components of I/O Subsystem
| Component | Role |
|---|
| Device Drivers | Interface between OS and device |
| Interrupt Handlers | Respond to device signals |
| I/O Scheduler | Manages request queue |
| Buffers & Caches | Temporary storage |
I/O Buffering
Buffering uses main memory as temporary storage during I/O operations to handle speed mismatches.
Why Buffering is Needed
- CPU faster than I/O devices
- Avoid data loss
- Improve system throughput
Types of Buffering
| Type | Description |
|---|
| Single Buffering | One buffer used |
| Double Buffering | Two buffers alternate |
| Circular Buffering | Multiple buffers in cycle |
Advantages
- Overlapping of I/O and CPU execution
- Reduced waiting time
- Smooth data transfer
Disk Storage
Disk Structure Components
| Component | Description |
|---|
| Platter | Circular disk surface |
| Track | Concentric circles |
| Sector | Smallest storage unit |
| Cylinder | Same track on all platters |
| Read/Write Head | Accesses data |
Disk Access Time
Disk Access Time = Seek Time + Rotational Latency + Transfer Time
| Term | Meaning |
|---|
| Seek Time | Head movement time |
| Rotational Latency | Wait for sector |
| Transfer Time | Actual data transfer |
Disk Scheduling
Disk scheduling decides the order of disk I/O requests to minimize seek time.
Disk Scheduling Algorithms
1. FCFS (First Come First Serve)
| Feature | Explanation |
|---|
| Order | Arrival order |
| Advantage | Simple |
| Disadvantage | High seek time |
2. SSTF (Shortest Seek Time First)
| Feature | Explanation |
|---|
| Selection | Nearest request |
| Advantage | Reduced seek time |
| Disadvantage | Starvation |
3. SCAN (Elevator Algorithm)
| Feature | Explanation |
|---|
| Movement | Back and forth |
| Advantage | Fair |
| Disadvantage | End delay |
4. C-SCAN
| Feature | Explanation |
|---|
| Direction | One direction only |
| Advantage | Uniform wait |
| Disadvantage | Extra movement |
5. LOOK / C-LOOK
| Feature | Explanation |
|---|
| Improvement | Stops at last request |
| Advantage | Efficient |
Comparison Table
| Algorithm | Starvation | Performance |
|---|
| FCFS | No | Poor |
| SSTF | Yes | Good |
| SCAN | No | Better |
| C-SCAN | No | Best |
RAID (Redundant Array of Independent Disks)
RAID combines multiple disks to improve performance, reliability, or both.
RAID Levels
| Level | Technique | Benefit |
|---|
| RAID 0 | Striping | High speed |
| RAID 1 | Mirroring | High reliability |
| RAID 2 | Hamming code | Error correction |
| RAID 3 | Byte-level striping + parity | |
| RAID 4 | Block-level striping + parity | |
| RAID 5 | Distributed parity | Balanced |
| RAID 6 | Dual parity | Fault tolerance |
Popular RAID Comparison
| RAID | Min Disks | Fault Tolerance |
|---|
| RAID 0 | 2 | None |
| RAID 1 | 2 | 1 disk |
| RAID 5 | 3 | 1 disk |
| RAID 6 | 4 | 2 disks |
Advantages of RAID
- Improved performance
- Data redundancy
- Fault tolerance
- High availability
Disadvantages
- Costly
- Complex setup
- Storage overhead
Quick Revision Table
| Topic | Key Focus |
|---|
| I/O Devices | Input–Output hardware |
| I/O Subsystem | OS management layer |
| Buffering | Speed mismatch handling |
| Disk Scheduling | Seek time reduction |
| RAID | Performance & reliability |
FILE SYSTEM
A File System is a method used by the Operating System to store, organize, manage, and protect data on storage devices such as hard disks and SSDs.
File Concept
A file is a named collection of related data stored on secondary storage.
Files provide a logical view of data storage to users and programs.
File Attributes
| Attribute | Description |
|---|
| Name | Human-readable identifier |
| Identifier | Unique file number |
| Type | Text, binary, executable |
| Location | Disk address |
| Size | File length |
| Protection | Access permissions |
| Time & Date | Creation, modification |
| Owner | User information |
File Operations
| Operation | Description |
|---|
| Create | Create new file |
| Open | Access file |
| Read | Read data |
| Write | Modify data |
| Close | Release file |
| Delete | Remove file |
File Organization and Access Mechanism
File organization defines how files are physically stored on disk.
Types of File Organization
| Type | Description | Use Case |
|---|
| Sequential | Records stored in order | Logs, tapes |
| Indexed | Index table for fast access | Databases |
| Hashed | Hash function maps keys | Large files |
File Access Mechanisms
| Access Method | Explanation |
|---|
| Sequential Access | Data accessed in order |
| Direct (Random) Access | Access any block directly |
| Indexed Access | Uses index for quick access |
Comparison Table
| Feature | Sequential | Direct | Indexed |
|---|
| Speed | Slow | Fast | Very fast |
| Flexibility | Low | High | High |
File Directories
A directory is a special file that stores information about other files.
Directory Structures
| Type | Description |
|---|
| Single-Level | One directory for all files |
| Two-Level | Separate directory per user |
| Tree-Structured | Hierarchical structure |
| Acyclic Graph | Allows shared files |
| General Graph | Allows cycles |
Directory Operations
| Operation | Description |
|---|
| Search | Find a file |
| Create | Add file |
| Delete | Remove file |
| Rename | Change name |
| Traverse | Move through structure |
File Sharing
File sharing allows multiple users or processes to access the same file.
Types of File Sharing
| Type | Explanation |
|---|
| Local Sharing | Within same system |
| Remote Sharing | Over network |
File Locking
| Lock Type | Purpose |
|---|
| Shared Lock | Multiple readers |
| Exclusive Lock | Single writer |
Consistency Problems
- Simultaneous write conflicts
- Data corruption
Solution: File locking and access control.
File System Implementation Issues
1. File Allocation Methods
| Method | Description | Issue |
|---|
| Contiguous | Continuous blocks | External fragmentation |
| Linked | Linked blocks | Slow access |
| Indexed | Index block | Extra overhead |
2. Free Space Management
| Method | Description |
|---|
| Bit Map | Bit per block |
| Linked List | Linked free blocks |
| Grouping | Groups of free blocks |
| Counting | Extents |
3. Directory Implementation
4. Disk I/O Performance
- Block size
- Cache usage
- Read-ahead
File System Protection and Security
Need for Protection
- Prevent unauthorized access
- Ensure data integrity
- Maintain privacy
Protection Mechanisms
1. Access Control
| Access Type | Meaning |
|---|
| Read | View content |
| Write | Modify content |
| Execute | Run file |
2. Access Control List (ACL)
| User | Permissions |
|---|
| Owner | RWX |
| Group | RW |
| Others | R |
3. Capability List
- Users possess capabilities
- More secure than ACL
4. Encryption
- Protects data from theft
- Used in modern file systems
5. Authentication
- Passwords
- Biometrics
- Digital certificates
Comparison: ACL vs Capability List
| Feature | ACL | Capability |
|---|
| Stored With | File | User |
| Security | Medium | High |
| Flexibility | High | Medium |
Exam-Friendly Summary
| Topic | Key Point |
|---|
| File Concept | Named data collection |
| File Access | Sequential, Direct, Indexed |
| Directory | File organization |
| File Sharing | Multi-user access |
| Implementation | Allocation & free space |
| Protection | Access control & security |