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
Paging in Operating System
Socho tumhare paas ek badi kitaab (Book) hai, jisme 100 pages hain. Tumhare bookshelf me jagah nahi ki pura book ek jagah rakho. Toh tum us kitab ke pages ko alag-alag shelf ke khaali jagah me rakh dete ho.
But yeh yaad rakhte ho ki kaunsa page kis shelf me rakha hai, taaki baad me easily dhoond sako.
Yahi kaam Operating System karta hai memory me!
Isse hi kehte hain Paging.
Definition – Paging Kya Hai?
Paging ek technique hai jisme Operating System:
-> Process ki memory ko todta hai chhoti-chhoti pages me
-> Physical memory (RAM) ko todta hai chhoti-chhoti frames me
-> Fir har page ko kisi bhi available frame me store karta hai (sequence me nahi)
Aur ek Page Table banta hai jo batata hai:
“Page 0 kaha gaya, Page 1 kaha gaya, Page 2 kaha gaya…”
Basic Concepts – 5 Important Terms
Term | Meaning (Easy) |
---|---|
Page | Logical memory ka ek fixed-size tukda |
Frame | Physical RAM ka ek fixed-size tukda |
Page Table | Ek table jo batata hai har page kis frame me hai |
Logical Address | CPU dwara banaya gaya address (virtual) |
Physical Address | Actual address in RAM (jaha data store hai) |
Paging Kyu Zaroori Hai?
Bina Paging:
Process ko ek badi continuous memory chahiye hoti hai
Memory me chhoti-chhoti khaali jagah hoti hai (external fragmentation)
Process memory me fit nahi ho pati
Paging ke Saath:
Process ke pages RAM ke kisi bhi frame me ja sakte hain
Memory ka achha use hota hai
No external fragmentation
Paging Kaise Kaam Karta Hai? (Step-by-Step)
Step 1: Memory ko Todna
Suppose process = 4 KB
Page size = 1 KB
→ Process will have 4 pagesRAM me bhi frames = 1 KB size ke hote hain
Step 2: Page Table Banana
Page Table ek table hoti hai jisme likha hota hai:
Page No | Frame No |
---|---|
0 | 3 |
1 | 6 |
2 | 1 |
3 | 4 |
Matlab:
Page 0 → Frame 3 me gaya
Page 1 → Frame 6 me gaya
…and so on
Step 3: Address Translation
Jab CPU data mangta hai, woh logical address bhejta hai (Page No + Offset)
Page No = Page Table se check karte hain → Frame No milta hai
Offset = Page ke andar ki position
Fir banta hai Physical Address = Frame Start Address + Offset
Example
Page/Frame size = 1 KB (1024 bytes)
Logical Address = 2049
Page Number = 2049 / 1024 = 2
Offset = 2049 % 1024 = 1
Page 2 → Frame 5 me hai (Page Table se mila)
Frame 5 ka address = 5 × 1024 = 5120
→ Physical Address = 5120 + 1 = 5121
Logical 2049 → Physical 5121
Flow
Logical Address (Page No + Offset)
↓
Page Table → Frame No
↓
Physical Address = Frame No + Offset
Real Life Analogy
Student (Process) = Many books
Books = Pages
Shelves (RAM) = Frames
Index Card (Page Table) = Bata raha hai ki kaunsa book kaunsa shelf me hai
Advantages
-> No External Fragmentation
-> Process memory kahin bhi RAM me store ho sakti hai
-> Swapping (Disk ↔ RAM) easy ho jata hai
-> Same-size blocks = Simple memory allocation
Disadvantages
-> Internal Fragmentation – Last page frame me thoda space waste ho sakta hai
-> Page Table Overhead – Large processes = badi page table
-> Slow Access – Har bar address translate karna padta hai
TLB – Speed Booster
TLB (Translation Lookaside Buffer) ek chhoti fast memory hoti hai CPU ke paas
Page Table me baar-baar dekhne se bachata hai
Recent page-frame mappings ko yaad rakhta hai
Agar CPU ko address TLB me mil gaya → Super Fast
Nahi mila → Page Table me jaake dhoondo