Web Hosting

Lecture 31 : Memory Management in Advanced Microprocessors

Memory Management
In advanced microprocessor, memory management becomes extremely important. Memory management is required due to the following two reasons.
  1. Limitation of physical memory
    A microprocessor has limited number of address lines. Hence the physical memory addressability is limited. Increasing the number of address lines is not attractive as it makes the architecture and design complex without significant gain. Packaging becomes difficult and expensive. Memory Management Unit (MMU) solves this problem by translating the virtual memory address into the physical memory address. Virtual memory can be many times larger than the physical memory. Only the programs currently required are brought from the secondary storage such as a hard disk to, the physical memory (RAM) for execution.
  2. Need for Protection
    In a multi-user operating system, there is a possibility that a user program can corrupt the operating system area or the area of some other user unless a protection mechanism is built. Hence each user should be protected from other users and the operating system should be protected from other user (task). The user (task) should be allowed to have a controlled access to the operating system resources. Hence various privilege levels are defined. For example, in a situation having 4 privilege levels, 0 is the highest privilege and 3 has the lowest privilege as shown in the figure. The figure shows a typical Unix operating system layout.
    It has to be noted that the user is at the lowest privilege level, i.e., privilege level 3 and the operating system Kernel is at the highest privilege level, i.e., privilege level 0.
Fig. 31.1   Protection mechanism and privilege levels
Kernel, System services and Application services constitute the operating system. The user or task sits at the lowest privilege level and can not access the resource available at higher privilege levels directly. Similarly, Task-1, Task-2 and Task-3 occupy different memory blocks and they are protected from each other.
A microprocessor such as 8086 does not provide this kind of protection. The Memory Management Unit (MMU) of advanced microprocessors such as 80286 incorporates this kind of protection for a multi-user operating system.
Role of Memory Management Unit (MMU):
The virtual address space of a microprocessor may be many times larger than the actual physical address space. This is desirable as a microprocessor is supposed to store large programs and data which can not be accommodated in the physical memory space. Usually programs and data are stored in a secondary storage such as a hard disk. The hard disk is in the virtual or logical address space but not in the physical address space. Faster memory such as RAM is used as the physical memory (Primary Storage).
Fig.31.2    Microprocessor interfacing with primary storage and secondary storage
When a microprocessor is to execute a program, it checks whether the program is available in the physical memory (RAM). If the program is not available in the physical memory, it is brought from the secondary memory to the physical memory for execution. If available space is inadequate in the physical memory, some less important or unused program can be swapped back to the secondary memory to create space.
Memory Management Unit (MMU)
Memory Management Unit within a microprocessor converts the virtual memory address into a physical memory address. Virtual memory address is sometimes referred as logical memory address.
MMU can convert logical address into physical address in two ways.
  1. Segment oriented approach:
    In this case, the logical memory space consists of memory segments of variable length. Each segment contains some data/ program as is described by a "descriptor". The segment "descriptor" contains the base address of the segment, segment size and other attributes. The descriptors of all segments are stored in a "descriptor table" located in the physical memory.
    The logical address of a memory location contains two parts, viz, segment selector and offset. The segment selector points to the segment "descriptor" in the descriptor table. From the "descriptor", the base address of the segment is obtained. The offset part of the logical address is added to the segment base to generate physical address of the memory.
2.   Page oriented approach:
In page oriented approach, the logical address space is divided into pages of fixed length. A page has 4 Kbytes. Since the MMU deals with smaller chunk of memory (4 Kbytes), it is easier and faster to swap back and forth between the secondary storage and the physical memory.
 

No comments:

Post a Comment