Computer Science – 16.1 Purposes of an Operating System (OS) | e-Consult
16.1 Purposes of an Operating System (OS) (1 questions)
Login to see all questions.
Click on a question to view the answer
Demand paging is a virtual memory technique where pages are only loaded into physical memory when they are actually needed (i.e., when a page fault occurs). Instead of loading the entire program into memory at once, only the pages that are required for the current execution are loaded. This significantly reduces the amount of memory required to run a program.
How it works:
- When the CPU requests a page that is not in RAM (a page fault), the MMU signals the operating system.
- The operating system locates the required page on disk (usually in the swap space).
- The operating system finds a free frame in RAM. If no frames are free, it selects a page to evict (using a page replacement algorithm like FIFO, LRU, or Optimal).
- The evicted page is written back to disk (if it has been modified).
- The requested page is read from disk into the free frame.
- The page table is updated to reflect the new location of the page in RAM.
- The MMU then translates the virtual address to a physical address and allows the process to continue execution.
Role in Overcoming Limitations: Demand paging allows programs to run even if they are larger than the available physical memory. It effectively extends the available memory by using the hard disk as an extension of RAM.
Performance Implications and Mitigation Strategies:
- Performance Implications: Page faults can be slow, as they involve disk I/O. Excessive page faults (thrashing) can severely degrade performance.
- Mitigation Strategies:
- Effective Page Replacement Algorithms: Using algorithms like LRU (Least Recently Used) or Optimal can reduce the number of page faults.
- Increasing RAM: More RAM reduces the likelihood of page faults.
- Prefetching: Predicting which pages will be needed in the future and prefetching them into RAM can reduce the latency of page faults.
- Working Set Model: Focusing on the program's working set (the set of pages it actively uses) and keeping those pages in RAM.