Brain Dump

MMU

Tags
comp-arch

Is a chip, commonly built directly into the CPU, that puts fences around areas of memory to ensure out of bound references will be refused (by throwing an interrupt).

The general algorithm for the MMU is:

  1. Receive address.
  2. Try to translate address according to programmed scheme.
  3. If the translation fails report an invalid address.
  4. Otherwise
    1. If the TLB contains the physical memory, get the frame from the TLB and then perform read/write on it.
    2. If the page exists in memory check if the process has permissions to perform the operations on the page. Meaning the process has access to the page and it has permission to read/write to that page.
      1. If so then do the dereference, provide the address and cache the result in the TLB.
      2. Otherwise trigger a hardware interrupt (the kernel will probably send a SIGSEGV to the process responsible).
    3. If the page doesn't exist in memory generate an interrupt.
      1. The kernel could realise that this page could either not be allocated on disk, allocate the page and try the operation again.
      2. Otherwise this is invalid access and the kernel will most likely send a SIGSEGV to the process.