TheHingineer

  • Operating System


  • OS Part-1

  • OS Part-2

  • OS Part-3

  • OS Part-4

  • OS Part-5

  • Logical and Physical Address Space in Operating System

    Addressing ek important concept hai jo memory management aur process execution me use hota hai. Jab ek program execute hota hai, toh uske liye memory addresses ka use hota hai. Ye addresses two types ke hote hain:

    1️⃣ Logical Address (Virtual Address)
    2️⃣ Physical Address


    🔹 What is Logical Address?

    ✅ Logical Address wo address hota hai jo CPU generate karta hai kisi program ke execution ke time par.
    ✅ Ye address User ko dikhai deta hai aur Process ke perspective se memory location ko represent karta hai.
    ✅ Logical Address Space ka matlab hai poore program ke execution ke dauraan jo logical addresses generate hote hain unka set.
    ✅ MMU (Memory Management Unit) Logical Address ko Physical Address me convert karta hai.

    💡 Example:

    Agar ek program execute ho raha hai aur usme int a = 10; declare kiya gaya hai, toh:
    ✔ CPU is variable a ko logical address 1001 assign karega.
    ✔ Lekin RAM me ye physical address 5001 par store ho sakta hai.


    🔹 What is Physical Address?

    ✅ Physical Address wo actual address hota hai jisme data RAM me store hota hai.
    ✅ Ye hardware level ka address hota hai jo OS aur MMU handle karti hai.
    ✅ Users ko physical address ka pata nahi chalta, kyunki unhe sirf logical address dikhai deta hai.

    💡 Example:

    Agar ek process ka logical address 0x1234 hai aur Memory Management Unit (MMU) base address 0x4000 use karti hai, toh:

    🔹 Physical Address = Logical Address + Base Address
    🔹 0x1234 + 0x4000 = 0x5234


    🔹 Logical vs Physical Address – Key Differences

    Feature Logical Address Physical Address
    Definition CPU ke dwara generate kiya gaya address Actual RAM ka address jisme data store hota hai
    Visibility User ko dikhai deta hai User ko nahi dikhai deta
    Conversion MMU Logical Address ko Physical me convert karta hai Ye RAM me actual store hota hai
    Modification OS ke dwara modify kiya ja sakta hai Directly modify nahi hota
    Security More secure Less secure compared to Logical Address

    🔹 How Logical Address is Converted to Physical Address?

    🔹 Logical Address se Physical Address ka conversion MMU (Memory Management Unit) karta hai.
    🔹 Base Register aur Limit Register ka use hota hai address translation ke liye.

    💡 Example (Address Translation with MMU)

    Agar ek process ka Base Address = 5000 aur Logical Address = 200, toh:

    👉 Physical Address = Base Address + Logical Address
    👉 5000 + 200 = 5200

    🖼 Diagram (Address Mapping)

    Logical Address → MMU → Physical Address
    (200)          (Base = 5000)        (5200)


    🔹 Why Do We Need Logical and Physical Address?

    ✅ Process Isolation: Har process apne logical address space me kaam karta hai, jo security provide karta hai.
    ✅ Memory Management: OS virtual memory ko efficiently manage karta hai.
    ✅ Multitasking Support: Multiple processes execute ho sakte hain bina physical address conflicts ke.


    🔹 Conclusion

    ✔ Logical Address CPU generate karta hai aur user ke perspective se hota hai.
    ✔ Physical Address actual RAM location hota hai jisme data store hota hai.
    ✔ MMU Logical Address ko Physical Address me convert karta hai.
    ✔ Address translation se Memory Management easy aur efficient banta hai.

    Scroll to Top