beautypg.com

1 overview of mmu – Renesas SH7781 User Manual

Page 174

background image

7. Memory Management Unit (MMU)

Rev.1.00 Jan. 10, 2008 Page 144 of 1658
REJ09B0261-0100

7.1

Overview of MMU

The MMU was conceived as a means of making efficient use of physical memory. As shown in
(0) in figure 7.1, when a process is smaller in size than the physical memory, the entire process
can be mapped onto physical memory, but if the process increases in size to the point where it
does not fit into physical memory, it becomes necessary to divide the process into smaller parts,
and map the parts requiring execution onto physical memory as occasion arises ((1) in figure 7.1).
Having this mapping onto physical memory executed consciously by the process itself imposes a
heavy burden on the process. The virtual memory system was devised as a means of handling all
physical memory mapping to reduce this burden ((2) in figure 7.1). With a virtual memory system,
the size of the available virtual memory is much larger than the actual physical memory, and
processes are mapped onto this virtual memory. Thus processes only have to consider their
operation in virtual memory, and mapping from virtual memory to physical memory is handled by
the MMU. The MMU is normally managed by the OS, and physical memory switching is carried
out so as to enable the virtual memory required by a process to be mapped smoothly onto physical
memory. Physical memory switching is performed via secondary storage, etc.

The virtual memory system that came into being in this way works to best effect in a time sharing
system (TSS) that allows a number of processes to run simultaneously ((3) in figure 7.1). Running
a number of processes in a TSS did not increase efficiency since each process had to take account
of physical memory mapping. Efficiency is improved and the load on each process reduced by the
use of a virtual memory system ((4) in figure 7.1). In this virtual memory system, virtual memory
is allocated to each process. The task of the MMU is to map a number of virtual memory areas
onto physical memory in an efficient manner. It is also provided with memory protection functions
to prevent a process from inadvertently accessing another process's physical memory.

When address translation from virtual memory to physical memory is performed using the MMU,
it may happen that the translation information has not been recorded in the MMU, or the virtual
memory of a different process is accessed by mistake. In such cases, the MMU will generate an
exception, change the physical memory mapping, and record the new address translation
information.

Although the functions of the MMU could be implemented by software alone, having address
translation performed by software each time a process accessed physical memory would be very
inefficient. For this reason, a buffer for address translation (the translation lookaside buffer: TLB)
is provided by hardware, and frequently used address translation information is placed here. The
TLB can be described as a cache for address translation information. However, unlike a cache, if
address translation fails—that is, if an exception occurs—switching of the address translation
information is normally performed by software. Thus memory management can be performed in a
flexible manner by software.