ACTIVITY – 6
Paging, Fragmentation, and Demand Paging in Memory
Management
1. Introduction
Memory management is a critical function of an operating system that optimizes the
allocation and deallocation of memory resources. This report discusses three essential
memory management concepts: paging, fragmentation, and demand paging.
2. Paging
2.1 Definition
Paging is a memory management scheme that eliminates the need for contiguous memory
allocation by dividing physical memory into fixed-size blocks called frames and logical
memory into pages of the same size.
2.2 How Paging Works
1. A process’s address space is divided into fixed-size pages.
2. The operating system maps these pages to available frames in physical memory.
3. A page table maintains the mapping between logical pages and physical frames.
2.3 Advantages of Paging
Eliminates external fragmentation.
Allows efficient memory utilization by enabling non-contiguous memory allocation.
Simplifies memory management through fixed-size units.
2.4 Disadvantages of Paging
Requires additional memory for page tables.
Introduces a slight overhead due to address translation.
3. Fragmentation
3.1 Definition
Fragmentation occurs when memory is inefficiently utilized, leading to wasted space. It is
categorized into two types:
3.2 Types of Fragmentation
a) Internal Fragmentation
Occurs when allocated memory is slightly larger than the requested memory.
Wastes small portions of memory within allocated blocks.
Common in fixed-partition allocation systems and paging.
b) External Fragmentation
Occurs when free memory is scattered across different locations, preventing
allocation of large contiguous blocks.
Common in dynamic partitioning systems.
3.3 Solutions to Fragmentation
Paging and Segmentation: Paging eliminates external fragmentation, while
segmentation minimizes internal fragmentation.
Compaction: Rearranges memory to create larger contiguous free blocks (used in
dynamic memory allocation).
Best-Fit Allocation: Tries to allocate memory efficiently by finding the smallest
suitable block.
4. Demand Paging
4.1 Definition
Demand paging is a technique in which pages are loaded into memory only when they are
needed, reducing initial memory load and improving efficiency.
4.2 How Demand Paging Works
1. When a process requests a page, the system checks if it is in memory.
2. If the page is not in memory, a page fault occurs.
3. The operating system retrieves the required page from disk and loads it into a free
frame.
4. The page table is updated to reflect the new mapping.
4.3 Advantages of Demand Paging
Reduces memory usage by loading pages only when needed.
Allows execution of large programs with limited RAM.
Minimizes disk I/O operations compared to loading entire programs at once.
4.4 Disadvantages of Demand Paging
Page faults introduce additional latency.
Requires sophisticated hardware support (page table and TLB).
Excessive paging can lead to thrashing, where the system spends more time handling
page faults than executing processes.
5. Conclusion
Paging, fragmentation, and demand paging are essential concepts in memory management.
Paging provides efficient and non-contiguous memory allocation, while fragmentation can
lead to memory wastage and is mitigated through techniques like compaction. Demand
paging optimizes memory usage by loading pages as needed, reducing unnecessary memory
consumption. Understanding these mechanisms is crucial for optimizing system performance
and resource utilization.