Memory management, I/O, file systems and OS security explain how an operating system provides safe and efficient resource abstraction. PSC questions often test paging, segmentation, virtual memory, page replacement, file allocation, disk scheduling, distributed OS and protection/security.
Engineering Definitions
Memory management
Standard definition: OS function that allocates, maps, protects and reclaims main memory.
Exam meaning: RAM allocation, mapping, protection र reclaim गर्ने OS function।
Paging
Standard definition: A memory management scheme dividing virtual memory into pages and physical memory into frames.
Exam meaning: Virtual memory pages र physical frames मा divide गर्ने scheme।
File system
Standard definition: OS component that organizes, stores, names and retrieves files on storage devices.
Exam meaning: Files/directories लाई storage मा organize र access गर्ने system।
Protection
Standard definition: Mechanisms that control access of processes/users to resources.
Exam meaning: Resource access permission/control गर्ने OS mechanism।
Concept Teaching
The OS creates abstractions: process instead of raw CPU, virtual memory instead of raw RAM, file instead of disk blocks and permission model instead of unrestricted hardware access. The exam expects both mechanism and tradeoff.
Memory Allocation and Fragmentation
Memory must be shared safely among processes.
- Contiguous allocation gives each process a continuous memory region.
- Fixed partitions can cause internal fragmentation.
- Variable partitions can cause external fragmentation.
- Compaction reduces external fragmentation but costs time.
- Swapping moves processes between memory and disk.
Paging and Segmentation
Paging and segmentation solve memory management differently.
| Scheme | Unit | Main point |
|---|---|---|
| Paging | Fixed-size pages/frames | Avoids external fragmentation |
| Segmentation | Variable-size logical segments | Matches program structure |
| Paged segmentation | Segments divided into pages | Combines ideas |
| Virtual memory | Logical address space larger than physical RAM | Uses disk backing and page fault handling |
Page Replacement
When memory is full, OS chooses a victim page.
- FIFO removes oldest loaded page.
- LRU removes least recently used page.
- Optimal removes page used farthest in future, theoretical benchmark.
- Clock approximates LRU using reference bit.
- Thrashing occurs when excessive paging dominates execution.
- Working set model tracks active pages of a process.
I/O and Disk Scheduling
I/O subsystem hides device details and schedules requests.
- Device driver translates OS requests to device commands.
- Buffering smooths speed mismatch.
- Caching stores frequently used blocks.
- Spooling queues jobs for devices such as printers.
- Disk scheduling algorithms include FCFS, SSTF, SCAN and C-SCAN.
- DMA improves block transfer efficiency.
File System
File systems manage names, directories, metadata and disk blocks.
| Allocation | Idea | Tradeoff |
|---|---|---|
| Contiguous | Consecutive blocks | Fast sequential, external fragmentation |
| Linked | Each block points next | No external fragmentation, slow random access |
| Indexed | Index block stores pointers | Supports direct/random access |
| Inode-based | Metadata with block pointers | Unix-like systems |
Distributed OS and Security
Distributed OS extends resource sharing across networked machines.
- Transparency hides location, migration and replication where possible.
- Distributed file systems provide remote file access.
- Authentication verifies user/process identity.
- Authorization enforces permissions/capabilities/ACLs.
- Least privilege reduces damage from compromise.
- Encryption, auditing and isolation strengthen security.
Engineering Mechanism
- Process generates virtual address.
- MMU translates virtual page to physical frame using page table/TLB.
- Page fault traps to OS if page is absent.
- OS loads page and may replace victim page.
- File system maps file offset to disk blocks.
- I/O manager schedules device request and driver performs operation.
- Security checks identity and permission before access.
Diagrams / Models To Draw
- Draw virtual address translation with page table and TLB.
- Draw page fault handling flow.
- Draw file allocation methods.
- Draw disk scheduling head movement.
- Draw OS protection ring/user-kernel mode concept.
Formulas, Algorithms and Rules
- Effective access time with TLB depends on hit ratio and memory access costs.
- Page number + offset forms virtual address.
- Internal fragmentation occurs inside allocated block/frame.
- External fragmentation occurs between allocated regions.
- Disk access time = seek time + rotational latency + transfer time.
| Concept | Purpose | Exam distinction |
|---|---|---|
| Paging | Virtual memory mapping | Fixed-size pages |
| Segmentation | Logical program units | Variable-size segments |
| TLB | Fast translation cache | Reduces page table access |
| Page fault | Page absent in memory | Trap handled by OS |
| File system | Name-to-block organization | Allocation method matters |
| Protection | Access control | Authentication differs from authorization |
Exam Point
- Differentiate internal and external fragmentation.
- Paging avoids external fragmentation but can have internal fragmentation.
- TLB caches address translations.
- LRU and FIFO are page replacement algorithms.
- Authentication is identity; authorization is permission.
- File allocation methods have clear tradeoffs.
Worked Example
If a process references a virtual page not in RAM, hardware raises a page fault. OS checks validity, finds free frame or replaces victim, reads page from disk, updates page table/TLB and restarts the instruction.
Subjective Answer Pattern
- Define memory management.
- Explain paging, segmentation and virtual memory.
- Discuss page replacement and thrashing.
- Explain I/O and disk scheduling.
- Describe file system allocation.
- Discuss distributed OS transparency and security controls.
Common Engineering Mistakes
- Confusing page and frame.
- Saying page fault is always program error.
- Mixing authentication and authorization.
- Assuming contiguous allocation has no fragmentation.
- Forgetting disk scheduling components.
MCQ Revision
- What does TLB store?
- Paging uses fixed or variable size?
- Which replacement is theoretical optimum?
- What is thrashing?
- Which file allocation supports random access well?
- Authentication means what?
Final Summary
- OS abstracts memory, storage and devices.
- Paging and virtual memory provide flexible address spaces.
- Page replacement affects performance.
- File systems map names to disk blocks.
- I/O management coordinates slow devices.
- Security protects OS resources through identity, permissions and isolation.