TheHingineer

  • Operating System


  • OS Part-1

  • OS Part-2

  • OS Part-3

  • OS Part-4

  • OS Part-5

  • Paging Combined with Segmentation in Operating System

    🔹 Introduction

    Paging aur Segmentation memory management techniques hain, jo processes ko efficiently memory allocate karne ke liye use hoti hain. Dono techniques ka combination ek hybrid approach provide karta hai, jise Segmented Paging kaha jata hai.

    ✅ Why Combine Paging & Segmentation?

    • Segmentation se logical division hoti hai, jo programming structure ko follow karti hai.

    • Paging se fixed-size blocks (pages) create hote hain, jo internal fragmentation ko reduce karta hai.

    • Dono ko combine karne se better memory utilization aur efficient address translation possible hoti hai.


    🔹 How Segmented Paging Works?

    Segmented Paging me process ko pehle multiple segments me divide kiya jata hai, aur fir har segment ko chhoti-chhoti pages me todh diya jata hai.

    👉 Logical Address Structure:

    Logical Address=(Segment Number, Page Number, Page Offset)

    🖼 Diagram: Segmented Paging Process

    Logical Address Space (Segments)
    +----------+----------+-------+
    | Segment 1| Segment 2| Stack |
    +----------+----------+-------+

    Segment 1 → Divided into Pages
    +————+————+————-+
    | Page 1 | Page 2 | Page 3 |
    +————+————+————-+

    Segment 2 → Divided into Pages
    +————+————+————-+
    | Page 1 | Page 2 | Page 3 |
    +————+————+————-+

    Physical Memory
    +—————–+—————–+——————+——————+
    | Page 1(S1)| Page 1(S2)| Page 2(S1)| Page 3(S2)|
    +—————–+——————+—————–+——————+

    (S1 = Segment 1, S2 = Segment 2)


    🔹 Address Translation in Segmented Paging

    Segmented Paging me Logical Address ko Physical Address me convert karne ke liye 2 tables use hoti hain:

    1. 1. Segment TableHar segment ke liye ek Base Address store karti hai.

    2. 2. Page TableSegment ke andar pages ke physical locations store karti hai.

    Steps of Address Translation:

    1️⃣ CPU Logical Address generate karta hai → (Segment Number, Page Number, Offset).
    2️⃣ Segment Table check hoti hai, jisme Segment Base Address milta hai.
    3️⃣ Segment ke andar Page Table access hoti hai, jo Page Number ka Physical Address deti hai.
    4️⃣ Page Base Address aur Offset ko combine karke Final Physical Address generate hota hai.

    Formula for Physical Address Calculation:

    Physical Address=(Base Address of Segment)+(Page Table Entry)+Offset


    🔹 Example of Segmented Paging

    Agar CPU ek Logical Address (Segment 1, Page 2, Offset 500) generate karta hai:
    1️⃣ Segment Table me Segment 1 ka Base Address = 4000 hai.
    2️⃣ Segment 1 ke Page Table me Page 2 ka Base Address = 8000 hai.
    3️⃣ Final Address Calculation:

    Physical Address=4000+8000+500=12500

    👉 Final Physical Address = 12500 bytes.


    🔹 Advantages of Segmented Paging

    ✅ Efficient Memory Utilization: Paging se internal fragmentation control hoti hai, aur segmentation logical grouping provide karta hai.
    ✅ Flexible Memory Management: Segments different size ke ho sakte hain, aur unke andar pages equal size ke hote hain.
    ✅ Logical View + Fixed Allocation: Program logically structured rehta hai, aur memory allocation fixed-size blocks me hoti hai.


    🔹 Disadvantages of Segmented Paging

    ❌ More Complex Address Translation: CPU ko dono tables (Segment + Page) access karni padti hai, jo paging aur segmentation ke comparison me slow ho sakti hai.
    ❌ Extra Overhead: Har segment ke liye ek Page Table maintain karni padti hai, jo additional memory consume karti hai.


    🔹 Comparison: Paging, Segmentation & Segmented Paging

    Feature Paging Segmentation Segmented Paging
    Division Type Fixed-size pages Logical segments Segments + Pages
    Fragmentation Internal Fragmentation External Fragmentation Minimal Fragmentation
    Memory Utilization Efficient, but fixed allocation Flexible, but fragmentation risk Best of both
    Mapping Complexity Simple Page Table Segment Table Both Segment & Page Tables

    🔹 Conclusion

    ✔ Segmented Paging ek hybrid approach hai jo segmentation aur paging ki best features ko combine karta hai.
    ✔ Address translation do tables (Segment Table + Page Table) ka use karti hai.
    ✔ Memory utilization aur fragmentation ke issues ko reduce karne ke liye yeh technique useful hai.

    Scroll to Top