CPU Memory Management MemMan Memory Management (Pentium). Logical Address: segment (16bit): offset(32 bit) Normally part of the code in the software module. (Also known as the virtual memory space). Linear Address: from 0 to (232 –1): 4Giga Bytes Flat address space of the Pentium CPU. Physical Address: The actual RAM memory address implemented on the system. Example: System runs software program(s) requiring a total of 1GB of RAM (logical address space) but only 256 MB (physical address space) has been installed. Memory Management – Translation between Logical and Physical Address. Benefits: Enables programs with large logical address space requirement to run in a smaller physical memory space (by storing some of the code on the disk and transferring to RAM when required - Disk Swapping) Pentium can run in either : Real Mode: – i.e.8086 segmentation. Does not allow multi-tasking as there is no protection for one process to interfere with another one. Or Protected Mode: - Each process runs in a separate code segment. Segments can have different privilege levels preventing the lower privilege process (such as an application) to run a higher privilege one (e.g. operating system). Pentium (when running in Protected Mode) has two independent Memory Management Facilities: 1. Segmentation 2. Paging 1 CPU Memory Management MemMan SEGMENTATION Pentium CPU has six 16 bit segment registers called SELECTORS Logical Address = SEGMENT + OFFSET (in SELECTOR) The information held in SELECTOR register is used by CPU to determine: (i) Start (Base) of Segment in the Linear Space (ii) Length of Segment (iii) Privilege Level of the Segment CPU Selectors provide index (pointer) to Segment Descriptors stored in RAM in the form of memory structures called Descriptor Table(s). Determination of the Linear Address There are two types of Descriptor Tables: • Global Descriptor Table : for code belonging to Operating System Segments Created by OS before CPU switched to Protected Mode. • Local Descriptor Table(s): for code belonging to running application(s). 2 CPU Memory Management MemMan PAGING. Paging is a mechanism which helps the Operating System to create VIRTUAL (faked) address space by swapping code between disk and RAM. This process is known as Virtual Memory Support. Paging is an address translation from the Linear to the Physical Address. The Linear Address Space is divided into fixed length (4kbyte) PAGES. Similarly, the Physical Address Space is divided into the same fixed length FRAMES. Within their respective address spaces pages and frames are numbered sequentially. Paging mechanism assigns a frame number to a given page number. The pages that have no frames assigned to them are stored on the disk. When the CPU needs to run the code on any nonassigned page it generates a Page Fault Exception, upon which the Operating system reassigns a currently non-used frame to that page and copies the code from that page on the disk to the newly assigned RAM frame. 3 CPU Memory Management Page Translation Mechanism. 4 MemMan CPU Memory Management MemMan The page mapping process is achieved by Operating System storing two types of Translation Tables in RAM: • • Page Directory Table (base in CPU) Page Table (for each running process) 5 - of pointers to Page Tables - of pointers to Memory Frames