Answer Operating systems 2. Consider the enhanced second-chance algorithm for pa
ID: 3750081 • Letter: A
Question
Answer Operating systems
2. Consider the enhanced second-chance algorithm for page replacement. Consider a system with 4 pages (this is entirely unrealistic, we are using this to examine how the algorithm works). Since the list of pages is considered to be a circular queue, we will describe the status (reference bit, modify bit) of the pages in order from the page which is pointed to by the page reference. In your demonstrations, show any changes to page status which occur (a) Show how the algorithm chooses a victim with status of pages: (1,1), (1,1) (b) Show how the algorithm chooses a victim with status of pages: (1,1), (1,0), (c) Show how the algorithm chooses a victim with status of pages: (1,0), (1,1), (d) Show how the algorithm chooses a victim with status of pages: (1,0), (1,0),Explanation / Answer
Enhaced second chance algorithm will have a reference bit(R),modified bit(M) for every page that enters into the queue.
The algorithm perform four passes over the circular queue with four possibilities as shown below:
(i) (0,0)-reference bit is 0 and modified bit is 0.
It is not referenced or modified recently and hence is replaced first.
(ii) (0,1)-reference bit is 0 and modified bit is 1.
It is not recently used but is modified so it takes the second priority to be considered.
(iii) (1,0)-reference bit is 1 and modified bit is 0.
It is recently used but is not modified so it gets the third priority.
(iv) (1,1)-reference bit is 1 and modified bit is also 1.
It is recently used as well as it is modified and hence it gets the fourth priority.
In the given question scenario:
(a) (1,1),(1,1),(1,1),(1,1)
Here it belongs to fourth possibility
All pages have both refence bits and modified bits set as zero.
So it chooses the pages in FIFO order.
(b) (1,1),(1,0),(0,0),(0,1)
The choice of victim is (0,0),(0,1),(1,0),(1,1)
The selection of pages is done based on the four cases explained above the question scenario.
(c) (1,0),(1,1),(0,1),(0,1)
The choice is (0,1),(0,1),(1,0),(1,1)
Here there are two pages with (0,1),(0,1). So they are selected based on FIFO.
(d) (1,0),(1,0),(1,0),(1,0)
Here all four pages have their reference bits as 1 and modified bits as 0.
So since all have same values, selection is done based on FIFO order.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.