OS Complete Notes
OS Complete Notes
I/O Devices & Subsystems ✦ I/O Buffering Techniques ✦ Disk Storage: HDD vs
SSD ✦ Disk Scheduling Algorithms ✦ RAID Levels
File Concept & Organization ✦ File Allocation Methods ✦ File Directories (Flat &
Hierarchical) ✦ File Sharing & Protection ✦ File System Implementation
1.1 Definitions
I/O Device Any hardware component that allows a computer to communicate with the outside
world, including input, output, and storage devices.
I/O Subsystem The part of the OS responsible for managing all I/O operations, providing a uniform
interface between devices and the rest of the system.
Device Driver A software module that translates OS commands into device-specific instructions,
acting as the interface between the OS and hardware.
Interrupt A signal sent by a device to the CPU indicating that it requires attention, allowing the
CPU to handle I/O asynchronously.
DMA (Direct Memory A mechanism allowing I/O devices to transfer data directly to/from memory without
Access) constant CPU involvement, increasing efficiency.
✔ Advantages
✔ Uniform interface hides device complexity from applications.
✘ Disadvantages
✘ Complex driver development for each device type.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 3
★ Applications
★ Printers, scanners, and input devices in office environments.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 4
2.1 Definitions
Buffering Temporary storage of data in a memory area (buffer) to smooth out differences in
speed between producer and consumer.
Single Buffering One buffer is used; the process must wait for the buffer to be consumed before
refilling it.
Double Buffering Two alternating buffers allow one to be filled while the other is being consumed,
improving throughput.
Circular Buffering A ring of multiple buffers; new data wraps around to reuse consumed buffer slots,
used in high-speed streams.
Spooling Simultaneous Peripheral Operations On-Line; uses disk as a large buffer for devices
like printers.
✔ Advantages
✔ Decouples producer and consumer speeds, preventing bottlenecks.
✘ Disadvantages
✘ Consumes additional memory for buffer storage.
★ Applications
★ Streaming platforms (Netflix, YouTube) use circular buffering for video.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 5
3.1 Definitions
HDD (Hard Disk Drive) A magnetic storage device with spinning platters and read/write heads that access
data by physical movement.
SSD (Solid State Drive) A non-volatile flash-based storage device with no moving parts, offering faster
access times and higher durability.
Seek Time Time taken for the disk head to move to the correct track on a platter.
Rotational Latency Time for the platter to rotate the correct sector under the read/write head.
Transfer Rate Speed at which data is read from or written to the storage medium.
NAND Flash The type of non-volatile memory used in SSDs; stores data as electrical charges in
floating-gate transistors.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 6
✘ Disadvantages
✘ Slow random access due to mechanical seek and rotation.
★ Applications
★ NAS (Network Attached Storage) for home and office backups.
✘ Disadvantages
✘ Higher cost per GB compared to HDD.
★ Applications
★ Operating system drives in laptops and desktops for fast boot.
★ Ultrabooks and mobile devices where form factor and power matter.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 7
4.1 Definitions
Disk Scheduling The method used by an OS to determine the order in which disk I/O requests are
serviced to minimize seek time.
Seek Time Time for the disk arm to position over the correct track.
FCFS First Come First Served — requests served in arrival order; simple but may cause
high seek movement.
SSTF Shortest Seek Time First — next request with minimum seek distance is served; can
cause starvation.
SCAN Disk arm moves in one direction serving requests, reverses at the end; like an
elevator.
C-SCAN Circular SCAN — after reaching end, arm returns to beginning without serving
requests on the way back.
FCFS First Come First Served Simple, fair Poor performance on scattered requests
SSTF Shortest Seek Time First Reduces seek time Starvation of distant requests
SCAN (Elevator)
Move in one direction, then reverse No starvation Long wait at extremes
C-SCAN Circular SCAN, return to start Uniform wait time Wasted return sweep
LOOK Like SCAN but reverses at last request Better than SCAN Slightly complex
✔ Advantages
✔ Disk scheduling reduces total seek distance, improving throughput.
✔ LOOK and C-LOOK are more efficient by not going to disk extremes.
✘ Disadvantages
✘ SSTF causes starvation for requests at disk extremes.
✘ SCAN has higher average wait time for requests just passed.
✘ SSD performance is less dependent on scheduling — algorithms matter more for HDD.
★ Applications
★ File servers handling many concurrent disk I/O requests.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 8
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 9
5.1 Definitions
RAID A storage technology that combines multiple disk drives into a single unit for
redundancy, performance, or both.
Striping Dividing data into chunks spread across multiple disks, increasing read/write speed
by parallelism.
Mirroring Maintaining identical copies of data on two or more disks, providing fault tolerance.
Parity Extra data computed from actual data that allows reconstruction of lost data if a disk
fails.
RAID 1 Mirroring; each disk duplicated; full fault tolerance at 50% storage efficiency.
RAID 5 Striping with distributed parity across all disks; tolerates 1 disk failure.
RAID 6 Striping with double distributed parity; tolerates 2 simultaneous disk failures.
RAID 10 Combination of RAID 1 (mirror) and RAID 0 (stripe); high performance + redundancy.
✔ Advantages
✔ RAID improves read/write performance through parallelism (RAID 0, 10).
✔ Fault tolerance protects data from single or double disk failure (RAID 1, 5, 6).
✔ RAID 5 offers a good balance of cost, capacity, and redundancy for servers.
✘ Disadvantages
✘ RAID 0 has zero fault tolerance — one disk failure loses all data.
✘ RAID 5 rebuild after failure is slow and risks data loss if another disk fails during rebuild.
✘ RAID is not a substitute for backup — it does not protect against accidental deletion.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 10
★ Applications
★ RAID 0: Video editing workstations needing fast scratch storage.
★ RAID 10: Databases and enterprise applications needing both speed and reliability.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 11
6.1 Definitions
File A named collection of related information recorded on secondary storage; the basic
unit of storage in an OS.
File Attribute Metadata stored with a file: name, type, size, location, protection bits, timestamps,
owner.
File Type Category of file format: executable (.exe), text (.txt), image (.jpg), audio (.mp3), etc.
File Operation Actions performed on files: create, read, write, seek, delete, truncate, append.
File Structure The internal organization of a file: unstructured byte stream, fixed-length records, or
variable-length records.
File Access Method How data within a file is retrieved: sequential, direct (random), or indexed access.
✔ Advantages
✔ Files abstract away hardware details, providing uniform access.
✘ Disadvantages
✘ Sequential access is slow for non-sequential data retrieval.
★ Applications
★ Text editors and log files use sequential access.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 12
Q: Discuss the organization of files within file systems, including contiguous, linked,
and indexed allocation methods.
7.1 Definitions
Contiguous Allocation Each file occupies a set of consecutive disk blocks; the directory stores the starting
block and length.
Linked Allocation Each block of a file contains a pointer to the next block; blocks can be scattered
anywhere on disk.
Indexed Allocation A special index block holds pointers to all data blocks of the file; supports direct and
random access efficiently.
FAT (File Allocation A linked allocation variant where all next-block pointers are stored in a central table
Table) in memory.
Inode In Unix/Linux, a data structure (index node) storing file metadata and pointers to data
blocks.
External Fragmentation Wasted disk space between files; a problem in contiguous allocation.
Internal Fragmentation Wasted space within an allocated block when file data does not fill it completely.
Linked Allocation
Block Data Next →
4 FileA[0] →7
7 FileA[1] → 11
11 FileA[2] → NULL
Indexed Allocation
Index Block Points To Block
[0] 4
[1] 7
[2] 11
[3] 15
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 13
Random Access Fast (start + offset) Slow (traverse list) Fast (index lookup)
Reliability Loses data if start lost Loses rest if pointer lost Loses all if index lost
✘ Disadvantages
✘ Severe external fragmentation over time.
★ Applications
★ CD-ROM and DVD file systems (ISO 9660) use contiguous allocation.
✘ Disadvantages
✘ Very slow random access — must traverse entire chain.
★ Applications
★ FAT12/FAT16/FAT32 file systems used in Windows 9x and USB drives.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 14
✔ No external fragmentation.
✔ Handles large files with multi-level indexing (single, double, triple indirect).
✘ Disadvantages
✘ Index block itself requires storage space overhead.
✘ For very small files, index block wastes more space than the file content.
★ Applications
★ Unix/Linux ext2, ext3, ext4 file systems use inode-based indexing.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 15
Q: Explain the structure and management of file directories, including hierarchical and
flat directory structures.
8.1 Definitions
Directory A special file that stores a list of file names and their associated metadata (attributes,
location) in a file system.
Single-Level (Flat) All files reside in one global directory; simple but causes naming conflicts in
Directory multi-user systems.
Two-Level Directory Separate directory per user under a master root directory; eliminates user-level
naming conflicts.
Tree-Structured Directories can contain subdirectories forming a tree; most modern OS use this
(Hierarchical) Directory structure.
Acyclic-Graph Directory Allows shared files/directories via links; a file can have multiple directory entries
pointing to it.
Absolute Path Full path from the root directory to a file, e.g., /home/alice/docs/[Link]
Relative Path Path relative to the current working directory, e.g., docs/[Link]
Mount Point A directory in the tree where another file system is attached (mounted), extending the
hierarchy.
TWO-LEVEL DIRECTORY:
Root ■■■ User_A ■■■ fileA1, fileA2
■■■ User_B ■■■ fileB1, fileB2
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 16
✘ Disadvantages
✘ All file names must be unique globally — causes conflicts in multi-user systems.
★ Applications
★ Early single-user OS (CP/M, MS-DOS without subdirectories).
✘ Disadvantages
✘ More complex implementation than flat directory.
✘ Cyclic links (in graph directories) require garbage collection for deletion.
★ Applications
★ Linux/Unix file system hierarchy (/home, /etc, /usr, /var).
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 17
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 18
Hard Link A directory entry that points directly to the inode of a file; the file exists as long as at
least one hard link exists.
Symbolic (Soft) Link A special file containing the path of another file; can cross file systems; breaks if the
target is deleted.
File Lock A mechanism preventing conflicting access; advisory locks warn processes,
mandatory locks are enforced by the OS.
Owner The user who created the file and has full control over access permissions.
Group A set of users who share the same access rights to a file as defined by the owner.
Unix Permission Bits 9-bit scheme: 3 bits each for owner, group, and others — read (r), write (w), execute
(x).
Capability A token held by a process that grants specific access rights to a file or object.
Encryption File content is encrypted at rest so unauthorized users cannot read data even with
physical disk access.
Journaling A log of upcoming changes; if a crash occurs mid-write, the journal allows the FS to
recover to a consistent state.
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection
Operating Systems — Complete Notes Page 19
rwxr-xr-- Owner ✔ ✔ ✔ 7
Group ✔ ✘ ✔ 5
Others ✔ ✘ ✘ 4
✔ Advantages
✔ ACLs provide fine-grained per-user access control.
✘ Disadvantages
✘ ACLs can grow large and complex in systems with many users.
★ Applications
★ Linux ext4, XFS, Btrfs use journaling for crash consistency.
★ Windows NTFS uses ACLs and EFS (Encrypting File System) for protection.
Notes prepared for academic study | All Units: I/O Devices · Buffering · Disk Storage · RAID · File Systems
I/O Devices | I/O Buffering | HDD vs SSD | Disk Scheduling | RAID | File Concept | File Allocation | Directories | Protection