Memory management unit
MMU, which could be used with the Motorola 68010|300x300px used with the Motorola 68020 A memory management unit (MMU), sometimes called paged memory management unit (PMMU), is a computer hardware unit that examines all references to…
≈ 11 min read
Memory management unit. encyclopegia.org, snapshot enwiki-001376891497. /a/memory-management-unit
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
MMU, which could be used with the Motorola 68010|300x300px used with the Motorola 68020 A memory management unit (MMU), sometimes called paged memory management unit (PMMU), is a computer hardware unit that examines all references to memory, and translates the memory addresses being referenced, known as virtual memory addresses, into physical addresses in main memory. In modern systems, programs generally have addresses that access the theoretical maximum memory of the computer architecture, 32 or 64 bits.
The MMU maps the addresses from each program into separate areas in physical memory, which is generally much smaller than the theoretical maximum. This is possible because programs rarely use large amounts of memory at any one time. Most modern operating systems (OS) use an MMU to provide virtual memory (VM) support.
The MMU tracks memory use in fixed-size blocks known as pages. If a program refers to a location in a page that is not in physical memory, the MMU sends an interrupt to the operating system.
The OS selects a lesser-used block in memory, writes it to backing storage such as a hard drive if it has been modified since it was read in, reads the page from backing storage into that block, and sets up the MMU to map the block to the originally requested page so the program can use it. This is known as demand paging.
Some simpler real-time operating systems do not support virtual memory and do not need an MMU, but still need a hardware memory protection unit. MMUs generally provide memory protection to block attempts by a program to access memory it has not previously requested, which prevents a misbehaving or malicious program from modifying or reading data belonging to another program.
In some early microprocessor designs, memory management was performed by a separate integrated circuit such as the VLSI Technology VI475 (1986), the Motorola 68851 (1984) used with the Motorola 68020 CPU in the Macintosh II, or the Z8010 and Z8015 (1985) used with the Zilog Z8000 family of processors. Later microprocessors (such as the Motorola 68030 and the Zilog Z280) placed the MMU together with the CPU on the same integrated circuit, as did the Intel 80286 and later x86 microprocessors.
Some early systems, especially 8-bit systems, used very simple MMUs to perform bank switching.
Examples
Most modern systems divide memory into pages that are in size, often with the capability to use so-called huge pages of or in size (often both variants are possible). Page translations are cached in a translation lookaside buffer (TLB). Some systems, mainly older RISC designs, trap into the OS when a page translation is not found in the TLB.
Most systems use a hardware-based tree walker. Most systems allow the MMU to be disabled, but some disable the MMU when trapping into OS code.
MIPS
The MIPS architecture supports one to 64 entries in the TLB. The number of TLB entries is configurable at CPU configuration before synthesis. TLB entries are dual.
Each TLB entry maps a virtual page number (VPN2) to either one of two page frame numbers (PFN0 or PFN1), depending on the least significant bit of the virtual address that is not part of the page mask. This bit and the page mask bits are not stored in the VPN2. Each TLB entry has its own page size, which can be any value from to in multiples of four.
Each PFN in a TLB entry has a caching attribute, a dirty and a valid status bit. A VPN2 has a global status bit and an OS assigned ID, which participates in the virtual address TLB entry match if the global status bit is set to zero. A PFN stores the physical address without the page mask bits.
A TLB refill exception is generated when there are no entries in the TLB that match the mapped virtual address. A TLB invalid exception is generated when there is a match, but the entry is marked invalid. A TLB modified exception is generated when a store instruction references a mapped address and the matching entry's dirty status is not set.
If a TLB exception occurs when processing a TLB exception, a double-fault TLB exception, it is dispatched to its own exception handler. MIPS32 and MIPS32r2 support 32 bits of virtual address space and up to 36 bits of physical address space. MIPS64 supports up to 64 bits of virtual address space and up to 59 bits of physical address space.
Sun MMU
The original Sun-1 is a single-board computer built around the Motorola 68000 microprocessor and introduced in 1982. It includes the original Sun 1 memory management unit that provides address translation, memory protection, memory sharing and memory allocation for multiple processes running on the CPU.
All access of the CPU to private on-board RAM, external Multibus memory, on-board I/O and the Multibus I/O runs through the MMU, where address translation and protection are done in a uniform fashion. The MMU is implemented in hardware on the CPU board. The MMU consists of a context register, a segment map and a page map.
Virtual addresses from the CPU are translated into intermediate addresses by the segment map, which in turn are translated into physical addresses by the page map. The page size is and the segment size is which gives 16 pages per segment. Up to 16 contexts can be mapped concurrently.
The maximum logical address space for a context is or The maximum physical address that can be mapped simultaneously is also . The context register is important in a multitasking operating system because it allows the CPU to switch between processes without reloading all the translation state information.
The 4-bit context register can switch between 16 sections of the segment map under supervisor control, which allows 16 contexts to be mapped concurrently. Each context has its own virtual address space. Sharing of virtual address space and inter-context communications can be provided by writing the same values into the segment or page maps of different contexts.
Additional contexts can be handled by treating the segment map as a context cache and replacing out-of-date contexts on a least-recently used basis. The context register makes no distinction between user and supervisor states.
Interrupts and traps do not switch contexts, which requires that all valid interrupt vectors always be mapped in page 0 of context, as well as the valid supervisor stack. The Sun-2 workstations are similar; they are built around the Motorola 68010 microprocessor and have a similar memory management unit, with pages and segments.
The context register has a 3-bit system context used in supervisor state and a 3-bit user context used in user state. The Sun-3 workstations, except for the Sun-3/80, Sun-3/460, Sun-3/470, and Sun-3/480, are built around the Motorola 68020, and have a similar memory management unit. The page size is increased to .
(The later models are built around the Motorola 68030 and use the 68030's on-chip MMU.) The Sun-4 workstations are built around various SPARC microprocessors, and have a memory management unit similar to that of the Sun-3 workstations.
Burroughs B5000 series, B6x00/B7x00/B5900/A-series/Unisys MCP systems
The Burroughs B5000 from 1961 was the first commercial system to support virtual memory (after the Atlas), has no need for an external MMU. The B5000 and its successors up to current Unisys ClearPath MCP (Libra) systems provide the two functions of an MMU — virtual memory addresses and memory protection — with a different architectural approach.
Rather than add virtual memory onto a processor not designed for virtual memory, it is integrated in the core design of the processor/system so there is no requirement for an external unit to add functionality of address translation or bounds checking, resulting in unprecedented memory safety and security. First, in the mapping of virtual memory addresses, instead of needing an MMU, the machines are descriptor-based.
The uppermost bit of a 48-bit memory word in the Burroughs B5000 series systems indicate whether the word is a user data or a descriptor/control word; descriptors were read-only to user processes and could only be updated by the system (hardware or operating system). Memory words in the B6x00/B7x00/B5900/A-series/Unisys MCP systems have 48 data bits and 3 tag bits (and later systems to current have 4 tag bits).
Words whose tag is an odd number are read-only to user processes – descriptors have a tag of 5 and code words have a tag of 3. Each allocated memory block is given a master descriptor with the properties of the block — physical address, size, and whether it is present in main memory or not; in which case, on first access, the block must be allocated, or if there is an address, it is an address on secondary storage and must be loaded to main memory.
All references to code and data are made using a descriptor. When a request is made to access the block for reading or writing, the hardware checks its presence via the presence bit (pbit) in the descriptor. A pbit of 1 indicates the presence of the block.
In this case, the block can be accessed via the physical main-memory address in the descriptor. If the pbit is zero, a pbit interrupt is generated for the MCP (operating system) to make the block present. If the address field is zero, this is the first access to this block, and it is allocated (an init (initial) pbit).
If the address field is non-zero, it is a disk address of the block, which has previously been rolled out — the block is fetched from disk, the pbit is set to one, and the physical memory address is updated to point to the block in memory. This makes descriptors equivalent to a page-table entry in an MMU system, but descriptors are free of a table.
All memory allocation is therefore completely automatic (one of the features of modern systems ) and there is no way to allocate blocks other than this mechanism. There are no such calls as malloc or dealloc, since memory blocks are also automatically allocated on pbit interrupt or discarded. The scheme is also lazy, since a block will not be allocated until it is actually referenced.
When memory is nearly full, the MCP examines the working set, trying compaction (since the system is segmented, not paged), deallocating read-only segments (such as code segments which can be restored from their original copy) and, as a last resort, rolling dirty (that is, updated) data segments out to disk. Another way these systems provide a function of an MMU is in protection.
Since all accesses are via the descriptor, the hardware can check that all accesses are within bounds and, in the case of a write, that the process has write permission. The MCP system is inherently secure and thus has no need of an MMU to provide this level of memory protection.
Blocks can be shared between processes via copy descriptors in process stacks (a stack is a special system structure representing the execution state of a process). Thus, some processes may have write permission, whereas others do not. Code segments are read-only, thus reentrant and shared between processes.
Copy descriptors contain a 20-bit address field giving the index of the master descriptor in the master descriptor array. This also implements a very efficient and secure Interprocess Communication (IPC) mechanism. Blocks can easily be relocated, since only the master descriptor needs to be updated when a block's status changes.
Another aspect is performance do MMU-based or non-MMU-based systems provide better performance? MCP systems may be implemented on top of standard hardware that has an MMU (for example, a standard PC). Even if the system implementation uses the MMU in some way, this will not be at all visible at the MCP level.
See also
Burroughs large systems descriptors Memory controller Memory protection unit
Text derived from https://en.wikipedia.org/w/index.php?oldid=1376891497 under CC BY-SA 4.0; modifications have been made.