Global Sources
EE Times-Asia
Stay in touch with EE Times Asia
 
EE Times-Asia > Memory/Storage
 
 
Memory/Storage  

Utilising a memory management unit

Posted: 25 Feb 2014  Print Version  Bookmark and Share

Keywords:Memory management units  MMU  embedded CPUs  assembly language  embedded systems 

Memory management units (MMUs) are integrated in, or available for, a broad range of embedded CPUs. Under some circumstances their use is mandatory; in other situations they might represent an unwanted overhead. This article looks at what MMUs do and how they might be applied. Process and thread models for multi-tasking are compared and contrasted, and an intermediate option is considered that might provide a compromise between security and performance requirements.

Physical and logical addresses
When you first start learning how to program, the concept of an address is unimportant, as high level languages insulate the programmer from such nastiness. It is only when a developer wants to understand or write assembly language or really appreciate what is happening with pointers that addresses become a concern.

Every byte of memory has a unique address. Actually that is not quite true, as some processor architectures utilise multiple address spaces, but ultimately every byte may be specified uniquely in some way. Commonly, a system has a single area of memory with a starting address of zero. This is not a firm rule, as the memory architecture could be set up such that the address space starts at some other value. Other systems have multiple areas of memory that may not be contiguous – maybe the program and data memory are separate, for example.

Such addresses are physical addresses and are the values emitted by the CPU and systems immediately around it, and are decoded by the memory system. For many systems, physical addresses correspond directly to logical addresses, which are the ones used by software. In other systems, there is no such matching. A difference between a logical and physical address may occur for a number of reasons.

If a CPU has a paged memory architecture, the software may work with shorter (logical) addresses than would be needed to access the complete (physical) address space. Adjusting the "page" moves a window of addresses through the physical address space. For example, the original x86 architecture used 16bit logical addresses (giving a 64K range) and 20bit physical addresses (accessing up to 1M). Setting up the base register enabled the logical address space to be mapped onto a 64K area within the 1M space (on a 16B boundary).

Paged addressing is uncommon nowadays. More typically CPUs use 32bit addresses to access a flat 4G address space. However, there may still be a non-correspondence between logical and physical addresses because a memory management unit (MMU) processes addresses emitted by the CPU. An MMU gives a lot of flexibility to remap physical memory to convenient logical addresses. It can also render parts of the physical address space inaccessible to software, which is a powerful protection mechanism.

Figure 1: Multitasking using a thread model.

Operating systems and multi-tasking
Most modern embedded systems are built using an operating system of some kind. This may be a simple multi-tasking kernel, or it may be a real-time operating system (RTOS) with a wide range of services, or it could be a "full" operating system like Linux. Broadly speaking, any kind of operating system supports a multi-tasking model, which may be "thread model" or "process model"; these two types are essentially characterized by their use or non-use of an MMU.

Multi-tasking – thread model
Most RTOS products on the market are thread model. This means that all the tasks' (now called threads) code and data occupy the same address space, along with that of the RTOS itself, as illustrated in figure 1.

1 • 2 Next Page Last Page



Article Comments - Utilising a memory management unit
Comments:  
*  You can enter [0] more charecters.
*Verify code:
 
Webinars

Seminars

Visit Asia Webinars to learn about the latest in technology and get practical design tips.

 
 
Back to Top