Operating System
OS Part-1
OS Part-2
- File Concepts and Access methods
- Free Space Management and Allocation methods
- Directory Systems and Protection
- File Organization, Sharing and Implementation issues
- Disk and Drum Scheduling
- I/O Devices Organisation & I/O Buffering
- I/O Hardware, Kernel I/O subsystem and Transforming I/O Requests to Hardware Operations
- Device Drivers and Path Management
- Device Driver Sub Modules and Procedure
- Device Scheduler and Handler
- Interrupt Service Routine (ISR)
- File System in Linux and Windows
OS Part-3
- Process and Process Control Block(PCB)
- Process Scheduling( Preemptive and Non Preemptive)
- Scheduling Algorithms
- Algorithm Evaluation
- Multiple Processor Scheduling
- Real Time Scheduling
- Operations on Processes
- Threads
- Inter-Process Communication
- Precedence Graphs
- Critical Section Problem
- Semaphores
- Classical Problems of Synchronization
- DeadLock
- Deadlock Prevention and Avoidance
- Deadlock Detection and Recovery
- Process Management in Linux
OS Part-4
- Memory Hierarchy in OS
- Concepts of Memory Management
- MFT and MVT
- Logical and Physical Address Space
- Swapping
- Contiguous and Non Contiguous Memory Allocation
- Paging
- Segmentation
- Paging Combined with Segmentation
- Structure and Implementation of Page Table
- Virtual Memory in OS
- Cache Memory Organization
- Demand Paging
- Page Replacement Algorithms
- Allocation of Frames and Thrashing
- Demand Segmentation
OS Part-5
- Distributed Operating System: Introduction and Types
- Distributed OS: Design Issues
- Distributed OS: File System
- Distributed OS: Remote File Access
- Remote Procedure Call(RPC)
- Remote Method Invocation(RMI)
- Distributed Shared Memory
- Parallel Processing and Concurrent Programming
- Security and Threats Protection in Distributed OS
- Security Design Principles and Authentication in Distributed OS
- Sensor Network and Parallel OS
Virtual Memory in Operating System
Introduction
Virtual Memory ek memory management technique hai jo processes ko required se zyada memory allocate karne ka illusion deti hai, even if physical RAM utni available na ho. Iska kaam secondary storage (HDD/SSD) ko RAM ke extension ke tarah use karna hota hai.
Why Virtual Memory?
-
Jab processes ka size available RAM se zyada hota hai tab Virtual Memory ka use hota hai.
-
Ye OS ko multiple processes efficiently manage karne me madad karti hai.
-
Disk space ko temporarily RAM ke tarah use karke execution allow karti hai.
How Virtual Memory Works?
Virtual Memory logical address space aur physical address space ko alag kar deti hai. Jab kisi process ko extra memory chahiye hoti hai, to OS uske kuch parts ko secondary storage me swap kar deta hai aur zaroorat padne par wapas RAM me load karta hai.
Main Steps:
-
1. CPU ek logical address generate karta hai.
-
2. Page Table mapping ke through ye address physical memory me translate hota hai.
-
3. Agar required page memory me hai to process continue hota hai (Page Hit).
-
4. Agar page memory me nahi hai to page fault aata hai aur OS us page ko secondary storage se RAM me load karta hai.
Diagram: Virtual Memory Working
CPU → Logical Address → Page Table → Physical Memory / Disk
Components of Virtual Memory
Virtual Memory ke kuch important components hote hain:
Component | Description |
---|---|
Paging | Process ko pages me divide karta hai aur physical memory me frames assign karta hai |
Page Table | Logical aur Physical address mapping store karta hai |
Swap Space | HDD/SSD ka part jo temporarily pages store karta hai |
Page Fault Handler | Jab required page memory me nahi hota, to usko RAM me load karta hai |
TLB (Translation Lookaside Buffer) | Fast memory jo frequently accessed pages ka translation store karti hai |
Demand Paging
Demand Paging ek aisi technique hai jo tabhi pages ko memory me load karti hai jab unki zaroorat ho.
Isse memory efficient hoti hai kyunki unused pages memory me load nahi hote.
Agar page memory me nahi hota to “Page Fault” hota hai aur OS us page ko disk se laake memory me load karta hai.
Diagram: Demand Paging Working
Process Requests Page → If Page in Memory → Execute
→ If Page NOT in Memory → Page Fault → Load Page from Disk
Page Replacement Algorithms
Jab memory full hoti hai aur naye page ko load karna padta hai, tab OS kisi existing page ko remove karta hai. Ye page replacement algorithms use hote hain:
Algorithm | Working | Pros & Cons |
---|---|---|
FIFO (First In First Out) | Sabse purana page replace hota hai | Simple but inefficient |
LRU (Least Recently Used) | Jo sabse kam use hua hai, usko replace karta hai | Better performance |
Optimal Page Replacement | Jo future me sabse late use hoga, usko replace karta hai | Best but practically impossible |
Advantages of Virtual Memory
Badi processes ko execute kar sakti hai even if RAM kam ho
Multiple programs ek saath efficiently execute hote hain
Less frequent program crashes due to memory limitations
Memory protection provide karta hai
Disadvantages of Virtual Memory
Agar zyada pages swap hone lage to system slow ho jata hai (Thrashing)
Disk pe frequent read/write hone se performance degrade ho sakti hai
Hardware aur software support chahiye hota hai (MMU – Memory Management Unit)
Conclusion
Virtual Memory ek powerful technique hai jo processes ko required se zyada memory allocate karne ka illusion deti hai.
Demand Paging aur Page Replacement Algorithms ka use karke OS efficiently memory manage karta hai.
Virtual Memory ka correct implementation system performance aur efficiency improve karta hai.