Paging
External fragmentation is avoided by using paging technique. Paging is a technique in which physical memory is broken into blocks of the same size called pages (size is power of 2, between 512 bytes and 8192 bytes). When a process is to be executed, it's corresponding pages are loaded into any available memory frames.
Logical address space of a process can be non-contiguous and a process is allocated physical memory whenever the free memory frame is available. Operating system keeps track of all free frames. Operating system needs n free frames to run a program of size n pages.
Address generated by CPU is divided into
- Page number (p) -- page number is used as an index into a page table which contains base address of each page in physical memory.
- Page offset (d) -- page offset is combined with base address to define the physical memory address.
Following figure show the paging table architecture.