Operating Systems · Paging
Pages and Frames Concept
Overview
Paging splits a process and main memory into small equal-sized parts in advance, so that parts of a process can be placed wherever free space exists.
The process is divided into pages and main memory into frames, with page size equal to frame size so that one frame holds exactly one page.
Key concepts
- Page: each of the small parts into which a process is divided.
- Frame: each of the small parts into which main memory is divided.
- Naming logic: a frame holds a page, and a page sits in a frame.
- Equal sizes: page size and frame size are the same, so one frame of main memory holds exactly one page of a process.
- Advance division: the process and memory are divided right away, not at the moment the need for division arises.
- Non-contiguous placement: because frames already exist as fixed slots, the pages of a process can be placed into non-contiguous frames directly.
How it works
- Do not postpone the splitting: when a process might have to be divided at some arbitrary time, split it immediately when it is brought in.
- Divide the process into small equal parts; each part is a page.
- Divide main memory into small equal parts of the same size; each part is a frame.
- Place the pages of the process into non-contiguous frames directly, since the frames already exist as fixed, pre-made slots; the operating system need not worry about dividing memory when the requirement arises.
- Because page size equals frame size, every page fits exactly into one frame: no page is split across frames and no frame is left with unusable leftover space.
Formulas
- : size of each small part into which the process is divided.
- : size of each small part into which main memory is divided.
- Consequence: number of frames needed by a process = number of its pages (one page per frame).
Comparison
| Aspect | Page | Frame |
|---|---|---|
| What is divided | The process | Main memory (physical memory) |
| Size | Same as frame size | Same as page size |
| Role | Goes and sits inside a frame | Holds one page |
| Contiguity | Pages of a process may be placed in non-contiguous frames | Frames are pre-existing fixed slots, used in any order |
Revision summary
- Small part of a process = page; small part of main memory = frame.
- A frame holds a page; a page sits in a frame.
- Page size must equal frame size, so that one frame holds exactly one page.
- Divide the process and divide memory in advance, not when the need for division arises.
- Since memory is already divided into frames, pages can go into non-contiguous frames without the OS working out the division again.
- No page is split across frames and no frame is left with unusable leftover space.
Previous-year exam insights
- Paging eliminates external fragmentation but can cause internal fragmentation: the last page of a process may be only partly filled, wasting up to (page size − 1) bytes in the last frame.
Asked inGATE 2021 - Paging incurs memory overheads: the page table itself occupies memory, and each memory access needs an extra page-table access (doubling effective access time) unless a TLB is used.
Asked inGATE 2021 - Page size is fixed for a given system and is a power of 2; all pages and all frames have this same size, so multi-level paging is used to handle large page tables, not to support pages of different sizes.
Asked inGATE 2021 - The logical (virtual) address is split into a page number and a page offset; the page number indexes the page table to give the frame number, and the physical address is the frame number concatenated with the same offset.
- Number of pages of a process = ceil(process size / page size);
number of frames in memory = memory size / frame size;
the page table has one entry per page of the process. - The page table maps page numbers to frame numbers and is kept in main memory; the page-table base register (PTBR) holds its starting address, and the TLB caches recent translations to speed up address translation.