coperating-systemvirtual-address-space

Why do we need address virtualization in an operating system?


I am currently taking a course in Operating Systems and I came across address virtualization. I will give a brief about what I know and follow that with my question.

Basically, the CPU(modern microprocessors) generates virtual addresses and then an MMU(memory management unit) takes care of translating those virtual address to their corresponding physical addresses in the RAM. The example that was given by the professor is there is a need for virtualization because say for example: You compile a C program. You run it. And then you compile another C program. You try to run it but the resident running program in memory prevents loading a newer program even when space is available.

From my understanding, I think having no virtualization, if the compiler generates two physical addresses that are the same, the second won't run because it thinks there isn't enough space for it. When we virtualize this, as in the CPU generates only virtual addresses, the MMU will deal with this "collision" and find a spot for the other program in RAM.(Our professor gave the example of the MMU being a mapping table, that takes a virtual address and maps it to a physical address). I thought of that idea to be very similar to say resolving collisions in a hash table.

Could I please get some input on my understanding and any further clarification is appreciated.


Solution

  • Could I please get some input on my understanding and any further clarification is appreciated.

    Your understanding is roughly correct.

    Clarifications:


    The reasons we use virtual memory are:


    1 - One risks is that if the working set of active VM pages across the the entire system is significantly greater than the available RAM, you can run into a problem called "thrashing". This is where the system gets overloaded with I/O traffic due to VM pages being moved between RAM and the paging device. The consequences can be dire.