DYNAMIC STORAGE-ALLOCATION PROBLEM How to satisfy a request of size n from a list of free holes o First-fit:Allocate the first hole that is big enough o Best-fit:Allocate the smallest hole that is big enough; must search entire list,unless ordered by size Produces the smallest leftover hole o Worst-fit:Allocate the largest hole;must also search entire list Produces the largest leftover hole First-fit and best-fit better than worst-fit in terms of speed and storage utilization
DYNAMIC STORAGE-ALLOCATION PROBLEM First-fit: Allocate the first hole that is big enough Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size Produces the smallest leftover hole Worst-fit: Allocate the largest hole; must also search entire list Produces the largest leftover hole How to satisfy a request of size n from a list of free holes First-fit and best-fit better than worst-fit in terms of speed and storage utilization
FRAGMENTATION External Fragmentation-total memory space exists to satisfy a request,but it is not contiguous o Internal Fragmentation-allocated memory may be slightly larger than requested memory;this size difference is memory internal to a partition,but not being used o 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, and is done at execution time ·I/O problem o Latch job in memory while it is involved in I/O o Do I/O only into OS buffers
FRAGMENTATION External Fragmentation – total memory space exists to satisfy a request, but it is not contiguous Internal Fragmentation – allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used 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, and is done at execution time I/O problem Latch job in memory while it is involved in I/O Do I/O only into OS buffers
PAGING 0 Logical address space of a process can be noncontiguous;process is allocated physical memory whenever the latter is available o Divide physical memory into fixed-sized blocks called frames(size is power of 2,between 512 bytes and 8,192 bytes) o Divide logical memory into blocks of same size called pages o Keep track of all free frames o To run a program of size n pages,need to find n free frames and load program o Set up a page table to translate logical to physical addresses o Internal fragmentation
PAGING Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter is available Divide physical memory into fixed-sized blocks called frames (size is power of 2, between 512 bytes and 8,192 bytes) Divide logical memory into blocks of same size called pages Keep track of all free frames To run a program of size n pages, need to find n free frames and load program Set up a page table to translate logical to physical addresses Internal fragmentation
ADDRESS TRANSLATION SCHEME o Address generated by CPU is divided into: Page number (p)-used as an index into a page table which contains base address of each page in physical memory Page offset (d)-combined with base address to define the physical memory address that is sent to the memory unit page number page offset p d m-n n For given logical address space 2m and page size 2n
ADDRESS TRANSLATION SCHEME Address generated by CPU is divided into: Page number (p) – used as an index into a page table which contains base address of each page in physical memory Page offset (d) – combined with base address to define the physical memory address that is sent to the memory unit For given logical address space 2m and page size 2 n page number page offset p d m - n n
PAGING HARDWARE logical physical address address f0000...0000 CPU p d f d f1111..1111 p physical memory page table
PAGING HARDWARE