Operating System Notes - Paging, Segmentation & Virtual Memory
1. Paging
Paging is a memory management scheme that allows the physical address space of a process to be
noncontiguous. It eliminates the need for contiguous allocation.
Logical Address is divided into: Page Number (p) and Offset (d)
Physical Address = Frame Number + Offset
The page number indexes a page table that contains the base address of each page.
2. Segmentation
Segmentation divides the memory into variable-sized segments based on logical divisions like functions,
arrays, etc.
Each segment has a segment number and an offset.
Segment Table stores: Base Address and Limit for each segment.
Segment Base Address Limit
0 1000 400
1 2000 600
3. Virtual Memory & Demand Paging
Virtual Memory gives the illusion of a large memory by using disk space. Demand Paging loads pages into
memory only when required.
If the page is not present, a Page Fault occurs and the page is loaded from disk.
4. Page Replacement
When no free frame is available, an existing page is replaced. This is handled by Page Replacement
Algorithms:
1. FIFO (First-In-First-Out): Replaces the oldest page.
2. LRU (Least Recently Used): Replaces the page that was least recently used.
3. Optimal: Replaces the page not used for the longest future duration (theoretical best).
Operating System Notes - Paging, Segmentation & Virtual Memory
Algorithm Type Complexity Performance Usage
FIFO Simple O(1) Poor Simulations
LRU Practical O(n)/O(1) Good Real-time OS
Optimal Theoretical High Best Analysis