In: Computer Science
A process contains eight virtual pages on disk and is assigned a fixed allocation of four-page frames in the main memory. The following page trace occurs: 1, 0, 2, 2, 1, 7, 6, 7, 0, 1, 2, 0, 3, 0, 4, 5, 1, 5, 2, 4, 5, 6, 7, 6, 7, 2, 4, 2, 7, 3, 3, 2, 3, 4
(a) Show the successive pages residing in the four frames using the LRU replacement policy. Compute the hit ratio in the main memory. Assume that the frames are initially empty.
(b) Repeat part (a) for the FIFO replacement policy.
(c) Compare the two hit ratios and comment on the effectiveness of using FIFO to approximate LRU with respect to this particular trace.
Given page-frames in main memory for a process = 4;
(a) LRU-Page-Access:
Miss | Miss | Miss | Hit | Hit | Miss | Miss | Hit | Miss | Hit | Miss | Hit | Miss |
1 | 0 | 2 | 2 | 1 | 7 | 6 | 7 | 0 | 1 | 2 | 0 | 3 |
1 | 0 | 0 | 2 | 1 | 7 | 6 | 7 | 0 | 1 | 2 | 0 | |
1 | 1 | 0 | 2 | 1 | 1 | 6 | 7 | 0 | 1 | 2 | ||
0 | 2 | 2 | 1 | 6 | 7 | 7 | 1 |
Hit | Miss | Miss | Miss | Hit | Miss | Hit | Hit | Miss | Miss | Hit | Hit | Miss |
0 | 4 | 5 | 1 | 5 | 2 | 4 | 5 | 6 | 7 | 6 | 7 | 2 |
3 | 0 | 4 | 5 | 1 | 5 | 2 | 4 | 5 | 6 | 7 | 6 | 7 |
2 | 3 | 0 | 4 | 4 | 1 | 5 | 2 | 4 | 5 | 5 | 5 | 6 |
1 | 2 | 3 | 0 | 0 | 4 | 1 | 1 | 2 | 4 | 4 | 4 | 5 |
Miss | Hit | Hit | Miss | Hit | Hit | Hit | Hit |
4 | 2 | 7 | 3 | 3 | 2 | 3 | 4 |
2 | 4 | 2 | 7 | 7 | 3 | 2 | 3 |
7 | 7 | 4 | 2 | 2 | 7 | 7 | 2 |
6 | 6 | 6 | 4 | 4 | 4 | 4 | 7 |
Total Hits: 17; Miss: 17; Total Access: 34;
Hit Ratio: Hit / Total Access = 17/34 = 0.5 = 50%
(b) FIFO-Access:
Miss | Miss | Miss | Hit | Hit | Miss | Miss | Hit | Hit | Miss | Hit | Miss |
1 | 0 | 2 | 2 | 2 | 7 | 6 | 6 | 6 | 1 | 1 | 0 |
1 | 0 | 0 | 0 | 2 | 7 | 7 | 7 | 6 | 6 | 1 | |
1 | 1 | 1 | 0 | 2 | 2 | 2 | 7 | 7 | 6 | ||
1 | 0 | 0 | 0 | 2 | 2 | 7 |
Miss | Hit | Miss | Miss | Miss | Hit | Miss | Hit | Hit | Miss | Miss | Hit | Hit |
3 | 3 | 4 | 5 | 1 | 1 | 2 | 2 | 2 | 6 | 7 | 7 | 7 |
0 | 0 | 3 | 4 | 5 | 5 | 1 | 1 | 1 | 2 | 6 | 6 | 6 |
1 | 1 | 0 | 3 | 4 | 4 | 5 | 5 | 5 | 1 | 2 | 2 | 2 |
6 | 6 | 1 | 0 | 3 | 3 | 4 | 4 | 4 | 5 | 1 | 1 | 1 |
Hit | Miss | Hit | Hit | Miss | Hit | Miss | Hit | Hit |
7 | 4 | 4 | 4 | 3 | 3 | 2 | 2 | 2 |
6 | 7 | 7 | 7 | 4 | 4 | 3 | 3 | 3 |
2 | 6 | 6 | 6 | 7 | 7 | 4 | 4 | 4 |
1 | 2 | 2 | 2 | 6 | 6 | 7 | 7 | 7 |
Total Hit: 17; Total Miss: 17; Total Access: 34;
Hit Ratio = Hit / Total Access = 17/34 = 0.50 = 50%
(c)In this particular trace both the LRU and FIFO have same hit ratio. They perform the same.