Please enable JavaScript.
Coggle requires JavaScript to display documents.
Virtual Memory (Demand Paging (Demand-Paging system (Similar to paging…
Virtual Memory
Demand Paging
When you load pages only as they are needed. It is commonly used in virtual systems. Pages are loaded only when demanded on program execution.
Demand-Paging system
Similar to paging system with swapping where processes reside in secondary memory. When we want to execute a process we swap it into memory.
Lazy swapper
Never swaps a page into memory unless the page will be needed. A swapper manipulates entire processes whereas pager manipulates individual pages of a process.
Copy-on-Write
Works by allowing the parent and child processes initially to share the same pages. The shared pages are marked as copy-on-write pages, meaning that if either process writes to a shared page, a copy of the shared page is created.
When a page is going to be duplicated using copy-on-write, it is important to note the location from which the free page will be allocated. A pool for free pages is provided for such requests.
OS typically allocate the pages using a technique known as zero-fill-on-demand. In this technique pages are zeroed out before being allocated.
Page Replacement
If no frame is free we fine one that is not currently being used and free it. We can free a frame by writing its content to swap space and changing the page table to indicate that the page is no longer in memory.
Routine when there is a page-fault. 1. Find the location of the desired page on the disk. 2. Find a free frame. 2.a If there is a free frame use it. 2.b Is there is no free frame use a page-replacement algorithm to select a victim. 2.c Write the victim frame to the disk; change the page and frame tables. 3. Read the desired page into the newly freed frame; change the page and frame tables. 4. Continue the user process from where the page fault occurred.
-
Trashing
If the number of frames allocated to a low-priority process falls bellow the minimum requires by the computer we must suspend that process execution.
The high paging activity is called trashing. A process is trashing if it is spending more time paging than executing.
Causes of Trashing
The main cause for trashing is when the CPU scheduler sees the CPU utilization decrease because of page-fault due to many processes having not many frames, It increases the degree of multiprogramming to increase CPU utilization but the new process created take away even more frames causing the CPU utilization to drop even more.
Allocation of Frames
-
Minimum number of Frames
We must allocate a minimum number of frames for better performance. As the number of page allocated to each process decreases the fault-rate increases and slows the process execution.
Allocation Algorithms
Equal Allocation
The easiest way to split m frames into n frames is to give everyone an equal share. The leftover frames can be used as free-frame buffer pool.
Proportional Allocation
The available memory is allocated to each process according to its size. With proportional we would split 62 frames between a process of 10 and a process of 127 pages by allocating 4 frames on the first and 57 on the second one.