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
Segmentation in Operating System
Segmentation kya hota hai?
Segmentation ek memory management technique hai jisme Operating System process ko logical parts (segments) me divide karta hai — jaise:
Code Segment – program ke instructions
Data Segment – variables aur constants
Stack Segment – function calls, return addresses, etc.
Har segment alag-alag size ka hota hai, kyunki unka kaam aur data alag hota hai.
Segmentation me memory ko logically divide kiya jata hai, fixed size me nahi — yeh Paging se alag hai.
Segmentation ki zarurat kyu padti hai?
Real programs ka structure logical hota hai — unme different parts hote hain:
Segment | Use |
---|---|
Code | Program instructions run karne ke liye |
Data | Variables store karne ke liye |
Stack | Function calls aur temporary values ke liye |
Agar sabko same size ke fixed blocks me rakhoge (jaise Paging me), to kuch memory waste ho sakti hai.
Segmentation se:
Logical grouping possible hai
Memory ko efficiently use kiya ja sakta hai
Har segment alag manage aur protect kiya ja sakta hai
Paging vs Segmentation
Feature | Paging | Segmentation |
---|---|---|
Division | Fixed-size blocks (Pages) | Logical parts (Segments) |
Size | Same size blocks | Alag-alag size blocks |
Programmer View | Hidden from programmer | Visible & logical (Code/Data/Stack) |
Segmentation kaise kaam karta hai?
Step 1: Process ko segments me baanto
Example:
Segment 0: Code – 1000 bytes
Segment 1: Data – 500 bytes
Segment 2: Stack – 300 bytes
Step 2: Segment Table banao
Operating System ek Segment Table banata hai har process ke liye, jisme likha hota hai:
Segment No | Base Address | Limit (Size) |
---|---|---|
0 (Code) | 2000 | 1000 |
1 (Data) | 4000 | 500 |
2 (Stack) | 5000 | 300 |
Base = Segment RAM me kaha se start ho raha hai
Limit = Segment ka size kitna hai
Step 3: Address Translation (Logical to Physical)
CPU logical address bhejta hai in 2 parts:
[ Segment Number | Offset ]
Operating System karta hai:
Segment Number se Segment Table me Base aur Limit nikaalta hai
Check karta hai ki Offset < Limit hai ya nahi
Agar valid hai → Physical Address = Base + Offset
Agar Offset zyada ho gaya → Segmentation Fault
Example:
Logical Address = Segment 1, Offset = 100
Segment 1 ka Base = 4000
Offset = 100
100 < 500 (Limit)
Physical Address = 4000 + 100 = 4100
Agar Offset = 600 hota:
600 > 500 → Segmentation Fault (invalid memory access)
Segmentation Flow Diagram:
Logical Address
↓
[ Segment Number | Offset ]
↓
Segment Table Look-up
↓
Base + Offset → Physical Address
↓
If Offset < Limit → Memory Access Allowed
Else → Segmentation Fault
Real-Life Example
Socho tumhara school bag (memory) hai.
Usme alag-alag compartments (segments) hain:
Books → Code
Stationery → Data
Lunchbox → Stack
Har cheez ka alag segment hota hai. Tumhe pata hai kis item ko kis compartment me rakhna hai — yehi segmentation ka concept hai.
Advantages
-> Logical program structure maintain hota hai
-> Har segment alag protect aur access control ke saath manage hota hai
-> Programmer ko memory structure clearly samajh aata hai
-> Internal fragmentation nahi hota (kyunki sizes exact hote hain)
Disadvantages
-> External Fragmentation – Memory ke beech khaali space chhut sakti hai
-> Segment Table banana aur maintain karna complex ho sakta hai
-> Memory allocation variable hone ki wajah se OS ka kaam thoda mushkil hota hai
Summary Table
Concept | Meaning |
---|---|
Segment | Logical part of a program (Code, Data, Stack) |
Base Address | Segment ka start point in RAM |
Limit | Segment ka size |
Logical Address | Segment No + Offset |
Physical Address | Base + Offset |
Segmentation Fault | Jab offset allowed size se zyada ho jaye |