150 likes | 279 Views
Scribe Mar 26, 2014 (Regular). Memory-Management Unit (MMU) Contiguous Memory Allocation Fragmentation. By Bandi Sumanth 11CS30006. Memory-Management Unit. MMU -> Hardware device that maps virtual address to physical address
E N D
ScribeMar 26, 2014(Regular) • Memory-Management Unit (MMU) • Contiguous Memory Allocation • Fragmentation By BandiSumanth 11CS30006
Memory-Management Unit • MMU -> Hardware device that maps virtual address to physical address • Consider a simple MMU scheme, which uses a relocation register • The value in the relocation address is added to every address generated by a user process at the time , it is sent to memory • For eg: if the relocation register contains addree 14000 • User access to address location 0 is dynamically relocated to location 14000 • Similarly, access to location 346 is mapped to location 14346
Memory-Management Unit • The user process deals with logical addresses (o to max) • It never sees the real physical addresses (R+0 to R+ max) • In this form of execution-time binding, the final location of a referenced memory address is not determined until the reference is made • The concept of a logical address space that is bound to a separate physical address space is centrary to proper memory managaement
Contiguous Memory Allocation • Multiple processes reside in memory • Each process is contained in single contiguous section of memory
Contiguous Memory Allocation • Main memory usually divided into two partitions • Resident operating system, usually held in low memory with interrupt vector • User processes then held in high memory
Multiprogramming with Fixed Partitions • Divide memory into several Fixed size partition • Each partition stores one process • Degree of multiprogramming limited by number of partitions • If a partition is free, load process from job queue • The OS keeps a table indicating which parts of memory are available and which are occupied • This method is was used by the IBM OS/360 operating sytem (called MFT - Multiprogramming with a Fixed number of Tasks)
Process 1 F r a g m e n t F r a g m e n t Process 3 F r a g m e n t Process 2 OS Partition 1 Partition 2 Partition 3 Multiprogramming with Fixed Partitions
Multiprogramming with Dynamic Partitions • Variable partition scheme • Hole – block of available memory; holes of various size are scattered throughout memory • Keeps a table of free memory • When a process arrives, it is allocated memory from a hole large enough to accommodate it • Process exiting frees its partition, adjacent free partitions combined • Operating system maintains information about:a) allocated partitions b) free partitions (hole)
Dynamic Storage-Allocation Problem • How to satisfy a request of size n from a list of free holes • First-fit: Allocate the first hole that is big enough (fast, but leads to fragments) • Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size (slow, but small leads to fragments). • Worst-fit: Allocate the largest hole; must also search entire list (slow, but leaves large holes) • First-fit and best-fit better than worst-fit in terms of speed and storage utilization
Hardware Support for Relocation and Limit Registers • Relocation-register scheme used to protect user processes from each other, and from changing operating-system code and data. • Relocation register contains value of smallest physical address; limit register contains range of logical addresses – each logical address must be less than the limit register • Context switch • MMU maps logical address dynamically
Fragmentation • Both the first-fit and best-fit strategies for memory allocation suffer from external fragmentation • As processes are loaded and removed from memory, the free memory space is broken into little pieces • External Fragmentation exists when there is enough total memory space to satisfy a request, but the available spaces are not contiguous; storage is fragmented into a large number of small holes • First fit analysis reveals that given N blocks allocated, another 0.5 N blocks will be lost to fragmentation • That is, one-third of memory may be unusabel! This property is known as 50-percent rule
External Fragmentation • Reduce external fragmentation by compaction • Shuffle memory contents to place all free memory together in one large block. • Compaction is possible only if relocation is dynamic (i.e., registers can be updated), and is done at execution time
Internal Fragmentation • Internal Fragmentation– allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used. • Occurs when memory is allocated in fixed size pieces