Memory Management Unit (MMU)

What is MMU (Memory Management Unit)?

MMU, a short for Memory Management Unit, refers to that particular hardware component in a computer which handles the virtual memory. It is usually found in the Central Processing Unit or the CPU of the computer system.

The MMU finds out the location of the information when it receives a request for data. This location can be on a permanent storage device or in the Random Access Memory or RAM.

It typically uses a table to match the physical memory addresses with the virtual ones.

Understanding Memory Management Unit

What is MMU

Memory Management Unit is a particular hardware unit that manages virtual memory.

Since the MMU divides this memory into pages, it is also called a Paged Memory Management Unit or PMMU as well.

Ideally, all memory references pass through the MMU which is responsible mainly for translating virtual memory addresses into physical addresses.

In addition to managing virtual memory, the MMU also helps with several other things at the same time, such as:

In the simpler architectures, especially in the 8-bit systems, it also helps in bank switching.

The range of addresses or the virtual address space used by the CPU is divided by the MMU into different pages.

Each page has a size expressed as a power of 2 and is often a few kilobytes long, though a few may be longer.

The offset within the page or the bottom bits of the address are left unchanged and the upper bits of the address represent the virtual page numbers.

The memory protection ability of the MMU can protect against a software bug or page fault.

Even the operating system can use it to disallow access to the memory by a specific errant program.

Ideally, that is the main reason that the operating system allocates virtual address space to each program.

The same virtual memory space can be used for each program due to the MMU, which also allows working with an adjoining virtual memory map even when the physical memory is split.

Since this virtual address space is different from the real physical map of the system memory, it allows writing, compiling and even linking applications so that these can be run within the virtual memory space.

The hardware in a virtual memory system needs to translate the address to do this. This is issued by the CPU to a physical address in the system memory.

The most important bits of the virtual address are used by the MMU for indexing entries in the translation table and for finding out which particular block address is being accessed.

It also decodes the data of the virtual addresses into the physical addresses in the actual system. All these processes are visible to the application and are carried out automatically in the hardware.

Apart from translating addresses, the MMU is also responsible for managing permissions for memory access and ordering as well as caching policies for every area of the memory.

MMU Working

The working principle of MMU involves handling all data request inputs that pass through it and determining whether the data has to be retrieved from the RAM or the ROM.

It also involves translating virtual memory addresses into physical addresses by matching them in the table or TLB.

Ideally, the working of the MMU hardware involves three basic functions such as:

Read Also:  What is Touchpad? Types, Uses, Pros & Cons

Typically, it is responsible for matching virtual and physical addresses by looking them up in the TLB. The working process is completed in the following steps:

However, if the address does not match, it signals an interrupt to the processor. It then switches tables to continue the search.

Therefore, the basic function of the MMU is to keep all functions related to the memory operating most efficiently.

For this, the working process includes different functions, apart from the basics mentioned above, such as:


MMU in Operating systems helps to control and manage the functions of the primary memory of the system. It is used to ensure better system performance, more concurrency, and proper utilization of memory.

It helps in moving processes from primary to secondary memory and vice versa, and also helps in tracking the allocated and unallocated memory.

There are a few specific techniques followed by the MMU in OS for better management. However, the three most significant processes are as follows:


In this method, the primary memory of the system is divided into several blocks, called segments. Each of these segments has a fixed length.

The length of each segment decides the available free memory amount in it.

There is also a starting address in each segment which is called the base address.

The distance from this base address to the actual position of the data helps in determining the location of the data item stored in the segment. This distance is called the displacement value or an offset.

When data needs to be acquired from the segment, the actual address of it is calculated by adding the base address and the offset value, both of which are defined in the program instruction itself.


This is the process that plays a vital role in ensuring the proper implementation and utilization of virtual memory by the computer system.

This is very important since it allows using more memory than what is available in the computer hardware.

In paging, the process address space is divided into blocks of the same size. These blocks are referred to as pages.

The size of each page is a power of 2, and the value ranges between 512 bytes and 8192 bytes. The number of pages denotes the actual size of the process.

Any smaller division of the memory is also divided into blocks of equal size and equivalent to the pages. These are called frames.

Paging offers several advantages such as:


In this technique, the operating system further ensures better management of the memory of the computer system. It includes two specific tasks, namely, swapping in and swapping out.

Both of these processes are valuable when a large program is executed or any operation that needs to be carried out on a large file.

How Does MMU Translate?

Translation of virtual addresses to physical addresses in the Memory Management Unit is typically done by software.

The operating system programs the MMU for the translation process and the hardware in a virtual memory system provides address translation.

Ideally, in an MMU, there are two components that help in the translation process. These are:

During the translation process, all the memory addresses issued pass through the MMU. This then checks the TLBs for any translation that has been used recently.

Read Also:  What is USB Type B? (Explained)

If there is no translation cached recently, the table walk unit will read the correct table entry or entries from the memory.

Next, in order to make the table entry, the translation table provides one entry per block in the table. This is usually done after splitting the virtual address space into blocks of equal size. Each block contains two parts such as:

When the translation happens, a table lookup is performed. For example, when the table entry is 0, the mapping for block 0 will be provided in the table, entry 1 for block 1, and so on.

This means that there will be an address of the matching block of physical memory in each entry along with the attributes to use for accessing that particular address.

MMU can also do multilevel translation by creating a multilevel table by dividing the virtual address space into big blocks.

An entry in the table may point to a block of equal size in the physical memory or to another table that has the block further subdivided into smaller ones.

This specific approach makes it easy to describe both larger and smaller blocks that differ in efficiency and levels of reads.

The operating system balances this by using the MMU and large mappings instead of smaller mappings for greater flexibility and optimum performance.

What is the Use of MMU?

One of the most significant tasks of the Memory Management Unit is to allow the system to multitask by running them as independent programs in their own individual virtual memory space.

The MMU also helps in modifying the physical address of the memory decoded by hard-wired logic so that the logical address avowed by the software is different from the physical address.

Generally, using the MMU turns out to be helpful in a number of contexts as follows:

Does the GPU Have MMU?

Yes, in the GpuMmu model, The GPU or the Graphics Processing Unit comes with its own Memory Management Unit.

This performs the same task that is to translate the virtual addresses to physical addresses but for the GPU exclusively.

The GPU MMU uses the hardware layout of the page tables. This is not known to the video memory manager and the Device Driver Interface or DDI abstracts it.

This abstraction supports translation at multiple levels, which includes a resizable root page table and a preset size page table.

How Does an MMU Provide Memory Protection?

The MMU provides protection to the memory by translating the linear or virtual address of a process to physical address.

There are significant functions performed by the MMU to provide protection to the memory. These are:

In addition to that, the MMU also provides the necessary data structures to the kernel for virtual memory and for implementing process swapping. This prevents the memory pages belonging to one particular process from being seen by another process but both can be seen by the dependent kernel.

Read Also:  What is an I/O Plate? (Explained)

How Does the MMU Use Page Tables?

The MMU uses the page tables or the table of items in the memory for translating the virtual addresses to physical addresses for the operating system.

However, the MMU does not have its own page tables and therefore has to share them with the operating system.

Ideally, these page tables come with at least one Page Table Entry or PTE on each page. These PTEs help in mapping the virtual page numbers to the physical page numbers in the primary memory in specific ways as follows:

Moreover, the PTE may also contain some other important information that helps in using the page tables by the MMU. For example, it may contain information about:

Ideally, when the TLB is searched by the MMU during translation, if there is a match found, called a TLB hit, the physical address is sent back and accessing the memory continues.

If there is a TLB miss, or no match is found, the MMU or the TLB miss handler of the operating system will look up in the page table for address mapping to find whether or not it exists. This process is known as a page walk.

It is written back in the TLB if it exists. This is important because the memory is accessed by the hardware via the TLB in a virtual memory system.

The faulting instruction may be resumed in parallel as well. The following translation will cause a TLB hit, and the memory access continues.

When the PTE denies access to a virtual page due to unallocated RAM for it, the MMU signals a page fault to the processor.

Such situations are handled by the operating system. It tries to find an unused RAM frame and set up a new PTE so that it can be mapped to the virtual address requested.

If there is no free RAM, then it will choose an existing or a ‘victim’ page with the help of a replacement algorithm and save it to the disk.

This process is called ‘paging.’ If there is a shortage of PTEs in the MMU, then the operating system must free one for new mapping.

Is MMU a Part of the CPU?

Yes, the Memory Management Unit of a computer is typically located in the Central Processing Unit or CPU.

However, there may be times when it may also operate as a separate Integrated Circuit or IC.

In fact, all x86-architecture CPUs from Intel and AMD, including the 64-bit variants, have this unit.

However, there are a few processors designed for embedded systems that may not have an MMU.

How to Setup MMU?

You can set up the MMU very easily in three simple steps that involve building the translation table that includes cache-able and buffer-able flags, virtual to physical address translation, access permissions and the domain number.

Then you have to store the location of the table created in a register and enable the caches and MMU by writing to the register.

Does MMU Have Its Own Memory?

No, the MMU usually does not have its own memory. Therefore, in order to operate, it has to rely on the data available in the main memory of the system.

This data is typically stored in the data structures such as the page tables and specifies which particular ranges of physical addresses match with the corresponding linear address ranges.

Which Address is Generated by the MMU?

The Memory Management Unit generates and computes the physical address and the logical address is typically generated by the CPU.


The Memory Management Unit ensures efficient functioning and allocation of memory to the processes which allows faster and better functioning of the processor and the computer system as a whole.

There are different aspects of it which are entailed in this article for your easy and better understanding.