TheHingineer

  • Operating System


  • OS Part-1

  • OS Part-2

  • OS Part-3

  • OS Part-4

  • OS Part-5

  • Paging in Operating System

    🔹 Introduction to Paging

    Paging ek memory management technique hai jo non-contiguous memory allocation ko support karti hai. Is technique me processes ko fixed-size blocks (pages) me todh diya jata hai aur phir unhe RAM me kisi bhi jagah store kiya jata hai.

    ✅ Why Paging?

    • Contiguous memory allocation me fragmentation problem hoti hai (external fragmentation).

    • Paging external fragmentation ko solve karta hai aur memory utilization improve karta hai.

    • Process ka pura address space ek saath available na bhi ho to bhi execution ho sakti hai.


    🔹 How Paging Works?

    Paging me logical address space ko fixed-size blocks (Pages) me divide kiya jata hai, aur physical memory (RAM) ko same size ke blocks (Frames) me divide kiya jata hai.

    👉 Process ka ek page kisi bhi frame me store ho sakta hai, aur Page Table mapping maintain karti hai.

    🖼 Diagram (Paging Process)

    Logical Address Space (Pages) Physical Memory (Frames)
    +----+----+----+ +----+----+----+
    | P1 | P2 | P3 | | F3 | F1 | F2 |
    +----+----+----+ +----+----+----+

    P = Page, F = Frame

    👉 Process ke pages kisi bhi available frames me store kiye ja sakte hain.

    Steps in Paging:

    1️⃣ Process ka Logical Address Space multiple Pages me divide hota hai.
    2️⃣ Physical Memory ko Frames me divide kiya jata hai.
    3️⃣ Page Table mapping maintain karti hai, jo batati hai ki kaunsa Page kaunsa Frame use kar raha hai.
    4️⃣ CPU jab bhi kisi memory address ko access karta hai, Page Table se Physical Address fetch kiya jata hai.


    🔹 Address Translation in Paging

    Paging me Logical Address ko Physical Address me convert karna padta hai, jo Page Table ke through hota hai.

    Address Calculation Formula:

    Physical Address=Frame Number+Offset

    Example:

    Agar Page Size = 4 KB ho aur CPU Logical Address = (Page Number = 2, Offset = 1024 bytes) ho, aur Page Table ke mutaabik Page 2, Frame 5 me hai, toh:

    Physical Address = (Frame5×4KB)+1024 Bytes 

    👉 Final Physical Address = 21504 bytes.


    🔹 Advantages of Paging

    ✅ No External Fragmentation: Kyunki pages aur frames fixed-size ke hote hain, toh chhoti-chhoti gaps nahi banti.
    ✅ Better Memory Utilization: Memory efficiently use hoti hai, kyunki pages alag-alag frames me store ho sakte hain.
    ✅ Support for Virtual Memory: Paging virtual memory ka bhi base provide karti hai.


    🔹 Disadvantages of Paging

    ❌ Extra Memory Overhead: Page Table ke liye additional memory chahiye hoti hai.
    ❌ Translation Time Increase Hota Hai: CPU ko Logical Address → Physical Address convert karne ke liye Page Table check karna padta hai, jo slow ho sakta hai.


    🔹 Conclusion

    ✔ Paging ek powerful memory management technique hai jo external fragmentation problem solve karti hai.
    ✔ Page Table mapping ke through Logical Addresses ko Physical Addresses me translate kiya jata hai.
    ✔ Modern operating systems (like Windows, Linux) paging ka use karte hain, aur Virtual Memory me bhi iska role hota hai.

    Scroll to Top