Memory Management n 1. Single contiguous allocation n 2. Partitioned organization: –Static, Dynamic n 3. (Pure) Paging
Memory Management n 1. Single Contiguous Allocation –Early, uni-programmed machines –Memory divided into 3 areas: Memory management developed over time (Historical Overview) (Historical Overview) OS (32K) User Job (64K) Wasted (160K) Memory (256K)
n Single Contiguous Allocation –Hardware : Bounds register, supervisor mode –Software : User job available memory? n If so, allocate and run to completion n If not, error –Advantage : simplicity –Disadvantages : poor M, P utilitization n job must fit into M
Memory Management n 2. Partitioned Organization –Early multiprogramming environment –Memory divided into partitions. Each holds 1 job. n E.g.
n Partitioned Organization –Software : n 1. Keep track of status of partitions –Size, Free or Allocated n 2. Which job gets M [Job Scheduler] n 3. Alloc : Free partition of sufficient size assigned n 4. Dealloc : Freed when job terminates –Hardware : n 2 bounds registers to bracket partition n Locks and keys [IBM] –Each partition has own protection key –When processor assigned, “key” in PSW = Key of partition
n Partitioned Organization –Two types of partitions : n Static Partitions –Memory divided into partitions according to OS or Operator specification –Each job specifies max memory req’d; memory management assigns partition of sufficient size –Appropriate if : size, frequency of jobs known –OW : wasteful of M n Estimated 75% wasted
n Partitioned Organization –Two types : n Dynamic Partitions –Created during job processing to match partition to job size –Need tables for allocating, deallocating partitions : Size, Location, Status. –E.g.
n Partitioned Organization –Dynamic Partitions n Jobs terminate, new partitions created from freed areas, subject to : –1. Free area Job size –2. If >, fragmentation –3. On deallocation, merge adjacent free areas n Implementation : –Table size varies n Append info to each partition and chain n Lists of free, alloc partitions
n 3. (Simple or Pure) Paging –Each job’s address space Equal pieces frames –Memory pieces of same size Frames (blocks) –User : n Sees logically continuous address space n But pages loaded into frames which are not contiguous –HW maps any page into any frame –Mapping : PMT (Separate registers, 1/Page) –Page size is critical (1-4K, in powers of 2) –Solves fragmentation problem without moving partitions Memory Management
(Pure paging)
n Paging –Hardware : n 1 register/page needed for memory mapping –High speed registers or memory locations (cache) n Dynamic Address Translation (DAT) –Divides EA into : 0 …. 7 8 … …. 31 Page number Byte offset
n Paging n Consider IBM example : –Page Size = 2 12 or 4096 bytes –Effective address (EA) = 24 bits –DAT : Divides EA into page index, byte displacement –PMT : Maps page number to frame number n Physical address of page n Add byte offset Address of operand –Software : Need 3 tables n 1 PMT/job, with 1 entry per page n A memory block (frame) table (MBT), with status info for each frame (if used, by whom) n A job table (JT), with 1 entry/job (Size, status, pointer to PMT)
n Paging –Advantages : n Facilitates multiprogramming by eliminating fragmentation (more jobs in memory, no compacting) n Facilitates sharing of info (memory) among jobs by incorporating pages in more than 1 job’s address space
n Paging –Disadvantages : n Page address mapping - HW costly, time-consuming n Tables : Memory required for PMTs, time to update n Internal fragmentation (page breakage) –Half page/job wasted on average –Tradeoff : n Small pages (min page wastage) vs n Large pages (reducing # entries in PMT) n Know average job size n Some memory may not be used (if #frames < address space) n Memory still contains infrequently used info n Job size must be Memory size