



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Belady Anomaly, Least Frequently Used, Most Frequently Used, Page Buffering Algorithm, Allocation of Frames, Minimum Number of Frames, Thrashing, Stack Replacement Algorithms. Above mentioned are key points of this lecture handout. Virtual University handout for introduction to operating system are in detail and explanatory.
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Operating Systems Lecture No. 40
Chapter 10 of the textbook Lecture 40 on Virtual TV
Belady’s Anomaly Page Replacement Algorithms ¾ Least Frequently Used (LFU) ¾ Most Frequently Used (MFU) ¾ Page Buffering Algorithm Allocation of Frames Minimum Number of Frames Thrashing
Consider the following example of the FIFO algorithm. Number of frames allocated = 3 Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Number of page faults = 9
1 1 1 4 4 4 5 5 5
Now an intuitive idea is that if we increase the number of frames allocated to 4 from 3, the page faults should decrease, but the following example demonstrates otherwise. Number of frames allocated = 4 Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Number of page faults = 10
1 1 1 1 5 5 5 5 4 4
2 2 2 2 1 1 1 1 5
This is due to the Belady’s Anomaly which states that “For some page replacement algorithms, the page fault rate may increase as the number of allocated frames increases.”
Belady’s anomaly
These are a class of page replacement algorithms with the following property: Set of pages in the main memory with n frames is a subset of the set of pages in memory with n+1 frames. These algorithms do not suffer from Belady’s Anomaly. An example is the LRU algorithm. Consider the following example which shows that LRU does not suffer from Belady’s anomaly for the given reference string. Number of frames allocated = 3 Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Number of page faults = 10
Number of frames allocated = 4 Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Number of page faults = 8
Another modification is to keep a pool of free frames, but to remember which page was in which frame. Since the frame contents are not modified when a frame is written to disk, the old page can be reused directly from the free-frame pool if it is needed before that frame is reused. No I/O is needed in this case. When a page fault occurs we check whether the desired page is in the free-frame pool. If it is not we must select a free frame and read into it. This method is used together with FIFO replacement in the VAX/VMS operating system.
If process P generates a page fault, page can be selected in two ways: Select for replacement one of its frames. Select for replacement a frame from a process with lower priority number. Global replacement allows a process to select a replacement frame from the set of all frames, even if that frame belongs to some other process; one process can take a frame from another. Local replacement requires that each process select from only its allocated frames. Consider an allocation scheme where we allow high priority processes to select frames from low priority processes for replacement. A process can select a replacement from among its own frames or the frames of any lower priority process. This approach allows a high priority process to increase its frame allocation at the expense of the low priority process.
Each process needs a minimum number of frames so that its execution may be guaranteed on a given machine. Let’s consider the MOV X,Y instruction. The instruction is 6 bytes long (16-bit offsets) and might span 2 pages. Also, two pages to handle source and two pages are required to handle destination (assuming 16-bit source and destination).
Minimum frames required to guarantee execution of the MOV X,Y instruction
There are three major allocation schemes: Fixed allocation In this scheme free frames are equally divided among processes Proportional Allocation Number of frames allocated to a process is proportional to its size in this scheme.
Instruction^
X
Y
0 1 2 3 4 5 6 7 8 9
Priority allocation Priority-based proportional allocation
Here is an example of frame allocation:
Number of free frames = 64 Number of processes = 3 Process sizes : P1 = 10 pages; P2 = 40 pages; P3 = 127 pages
Fixed allocation 64 / 3 = 21 frames per process and one put in the free frames list
Proportional Allocation ¾ si = Size of process Pi ¾ S = ∑ si ¾ m = Number of free frames ¾ ai = Allocation for Pi = (si / S) * m a1 = (10 / 177) * 64 = 3 frames a2 = (40 / 177) * 64 = 14 frames a3 = (127 / 177) * 64 = 45 frames ¾ Two free frames are put in the list of free frames
If a process does not have “enough” pages, the page-fault rate is very high. This leads to low CPU utilization. The operating system thinks that it needs to increase the degree of multiprogramming, because it monitors CPU utilization and find it to be decreasing due to page faults. Thus another process is added to the system and hence thrashing occurs and causes throughput to plunge. A process is thrashing if it is spending more time paging (i.e., swapping pages in and out) than executing. Thrashing results in severe performance problems: Low CPU utilization High disk utilization Low utilization of other I/O devices
Thrashing
The figure shows that as the degree of multiprogramming increases CPU utilization also increases, although more slowly, until a maximum is reached. If the degree of multiprogramming is increased further, thrashing sets in and CPU utilization drops sharply. At this point we must decrease the degree of multiprogramming. We can limit