.. _mem_hw: ################################### Memory Management Hardware ################################### Memory Hierarchy ================================= .. index:: cache Computers have several different types of memory. This memory is often viewed as a hierarchy as shown below. .. figure:: memory_hierarchy.png :align: center Our main concern here will be the computer's main or RAM memory. The cache memory is important because it boost's the speed of accessing memory, but it is managed entirely by the hardware. The rotating magnetic memory or disk memory is used by the :ref:`virt_mem`. .. _mmu: Memory Management Unit ================================= .. index:: Memory Management Unit As a program runs, the memory addresses that it uses to reference its data is the :term:`logical address`. The real time translation to the :term:`physical address` is performed in hardware by the CPU's :ref:`mmu` (MMU). The MMU has two special registers that are accessed by the CPU's control unit. A data to be sent to main memory or retrieved from memory is stored in the `Memory Data Register` (MDR). The desired logical memory address is stored in the `Memory Address Register` (MAR). The address translation is also called address binding and uses a memory map that is programmed by the operating system. .. note:: The job of the operating system is to load the appropriate data into the MMU when a processes is started and to respond to the occasional :ref:`page_fault` by loading the needed memory and updating the memory map. .. figure:: mmu.png :align: center Before memory addresses are loaded on to the system bus, they are translated to physical addresses by the MMU.