0
votes

I'm under-grad student so I'm not sure my writing are 100% accurate. It mostly based on what I understood from our online lecture that happened couple of week back and resource I have read and watched online.

So during our online classes on Memory Management in OS we touch upon use of MMU (which is dedicated hardware shipped with every CPU packages) which is used for address translation of Virtual address to Physical address.

Now here, what I understood from online resources like youtube and wikipedia.

When a program is compiled the compiler or the linker would generate the virtual address space for the program (so it possible that two process can have same virtual address and it also help it program in attaining contiguous memory while it could be possible pages are arrange different in RAM) I'm not entirely sure how this work with interpreter lang though.

Operating system also maintain a Page Table(locate in DRAM) for each process which is data structure (like hash map) of the virtual address to physical address in DRAM.

The CPU also has a dedicate cache called TLB to assist CPU in this job to avoid wasting its cycle for getting the physical address location on DRAM from page table since cache is closer to CPU it probably faster.

Actual Physical memory could be smaller than the Virtual address space which would require OS to swap page(also called page-out) to disk (and reference is maintain in page table of location on disk where it is stored) if there is no room for it. (which is called Virtual memory)

When the process runs, if the CPU get a virtual address it look up TLB, if it misses, it perform a lookup on the process Page table to access the address of page and where it is located and perform the translation like hashMap[virtual address] + offset = DRAM address

If the page exist in DRAM all work fine. But if the page does not exist in DRAM it generate a hardware fault upon which the OS bring those page from disk to DRAM page also updating the Page table entry with new address.

During this whole thing I don't understand or confused with

  • Where does the MMU fit what does it do since the address translation and page-in / page out is done by CPU and OS?

  • How is the Virtual address space assign in interpreted lang?

1
You said it yourself " MMU (which is dedicated hardware shipped with every CPU packages) which is used for address translation of Virtual address to Physical address."wxz
@wxz yes, I realise that now.Vicky

1 Answers

1
votes

Where does the MMU fit what does it do since the address translation and page-in / page out is done by CPU and OS?

The MMU is part of a modern CPU. The virtual to physical address translation is done by the MMU / CPU hardware.

The Operating System kernel (software) is responsible for making sure that that the MMU is correctly configured (so that the correct pages are mapped into user-space processes address spaces), and for handling the page fault interrupts generated by the MMU. It also deals with the higher level functions such as:

  • swapping pages in and out,
  • keeping track of which pages are clean,
  • ensuring that there is a pool of clean pages that can be evicted if there is a page fault,
  • dealing with scheduling issues such as killing processes that are causing thrashing
  • and so on.

How is the Virtual address space assign in interpreted lang?

It is the same as for a non-interpreted programming language. In the interpreted case, the interpreter is a user-space (non-privileged) program. The code that it is interpreting is ... data for the interpreter.