Demand paging
Demand Paging Demand paging is a memory management technique employed by operating systems to efficiently utilize memory resources on a system. It involves d...
Demand Paging Demand paging is a memory management technique employed by operating systems to efficiently utilize memory resources on a system. It involves d...
Demand paging is a memory management technique employed by operating systems to efficiently utilize memory resources on a system. It involves dividing the available physical memory (RAM) into fixed-size units called pages. Each page has its own address in the memory space.
Key Features of Demand Paging:
Division of Physical Memory: The entire physical memory space is divided into equal-sized pages.
Address Translation: When a program tries to access memory, it translates the virtual address used in the program into a physical address using a page table. The page table maps virtual pages to physical pages.
Allocation and Deallocation: When a program requires more memory than a single page, it can be allocated additional pages from the free pool in memory. These pages are then added to the page table.
Page Fault: If the requested page is not currently in memory, a page fault occurs. This means the program has to wait for the page to be brought in from secondary storage (e.g., hard disk).
Benefits of Demand Paging:
Increased Memory Utilization: By dividing memory into larger units, demand paging allows for efficient use of available memory.
Improved Memory Protection: Demand paging provides memory protection, where processes cannot access memory regions that are not allocated to them.
Supports Virtual Memory: Demand paging enables the use of virtual memory, which is larger than physical memory, by dividing the virtual address space into pages.
Drawbacks of Demand Paging:
Slower Memory Access: Memory access through the page table can be slower than accessing memory directly, due to the need for page translation.
Increased Context Switching Overhead: Maintaining the page table and page replacement mechanisms adds overhead to the system.
Requires Memory Management: Programmers need to manage memory allocation and deallocation to ensure efficient memory utilization.
Examples:
A process may be allocated 10 pages of memory, divided into 4 pages each.
The operating system uses a page table to keep track of which pages are currently in memory and which are in secondary storage.
When a program requires 15 pages of memory, the operating system may allocate 3 pages from different pages in memory to fulfill the request