Segmentation क्या है?
Segmentation एक memory management technique है जिसमें process को logical parts (segments) में divide किया जाता है।
ये parts program के structure के अनुसार होते हैं, जैसे:
- Code Segment
- Data Segment
- Stack Segment
हर segment का size अलग-अलग हो सकता है।
Basic Concept
- Process को segments में divide किया जाता है
- हर segment को memory में अलग-अलग जगह रखा जा सकता है
- हर segment का अपना base address और limit होता है
Segment Table
Segment Table में हर segment के लिए दो चीजें store होती हैं:
- Base → segment की starting address
- Limit → segment का size
Address Structure
Logical Address दो भागों में होता है:
- Segment Number (s)
- Offset (d)
Address Translation
CPU Logical Address देता है:
(s, d)
Step:
- Segment Table में segment number खोजा जाता है
- Check करते हैं कि offset < limit है या नहीं
- अगर valid है → Physical Address = Base + Offset
Formula (Important)
Physical Address = Base + Offset
Example (Numerical)
Segment Table:
| Segment | Base | Limit |
|---|---|---|
| 0 | 1000 | 400 |
| 1 | 2000 | 300 |
| 2 | 3000 | 500 |
Logical Address = (1, 150)
Solution
Step 1: Segment Number और Offset
Segment = 1
Offset = 150
Step 2: Limit check करो
Segment 1 की limit = 300
Offset = 150 < 300 → Valid
Step 3: Physical Address निकालो
Physical Address = Base + Offset
= 2000 + 150
= 2150
Final Answer: Physical Address = 2150
Advantages of Segmentation
- Program को logical तरीके से divide करता है
- Easy to understand और manage
- Different segments को अलग protection दिया जा सकता है
Disadvantages of Segmentation
- External Fragmentation होती है
- Management complex हो सकता है
- Segment Table की जरूरत होती है
Short Conclusion
Segmentation एक non-contiguous memory allocation technique है जिसमें process को logical segments (code, data, stack) में divide किया जाता है। Segment Table के base और limit की मदद से address translation होता है। इसमें flexibility होती है लेकिन external fragmentation की समस्या होती है।