GATE / CS ARCHIVE

SIMILAR QUESTIONS / OPERATING SYSTEMS

Trace LRU faults from initially empty frames

3 questions solved the same way, newest first. Back to Operating Systems

How these are solved

Each supplies an explicit reference string, empty fixed-size frame pool and LRU. Track recency on every hit and replace the oldest last-use page on a miss.

2 marks · NAT
Report issue

Virtual Memory & Paging

Question 64, GATE 2022: Four initially empty demand-paging frames use LRU. References: 7,2,7,3,2,5,3,4,6,7,7,1,5,6,1. Find page faults/accesses rounded to one decimal.
Tap to enlarge
Answer & solution

Official answer: 0.6

Step through it (17 steps)

Simulating four LRU frames gives faults at reference positions 1, 2, 4, 6, 8, 9, 10, 12, 13, for the values 7, 2, 3, 5, 4, 6, 7, 1, 5. The other six references hit. In particular, the second consecutive 7 hits, and the last 6 and 1 both remain resident. Hence the fault rate is 9/15=0.6.

Maintain recency oldest→newest after each access: [7]; [7,2]; [2,7]; [2,7,3]; [7,3,2]; [7,3,2,5]; [7,2,5,3]; [2,5,3,4]; [5,3,4,6]; [3,4,6,7]; [3,4,6,7]; [4,6,7,1]; [6,7,1,5]; [7,1,5,6]; [7,5,6,1]. On a full-frame miss remove the oldest before appending; on a hit move the referenced page to newest.

Original paper, page 40 · Answer key

1 mark · NAT
Report issue

Virtual Memory & Paging

Question 20, GATE 2014: Three initially empty page frames use LRU replacement. Count faults for page references 4,7,6,1,7,6,1,2,7,2.
Tap to enlarge
Answer & solution

Official answer: 6

Step through it (12 steps)

Step 1: Maintain recency on hits as well as on insertions. Write resident pages from least to most recently used. The first three references fault and produce [4], [4,7], [4,7,6]. Step 2: Reference 1 faults and evicts 4, giving [7,6,1]. The following hits on 7,6,1 change the order to [6,1,7], [1,7,6], [7,6,1]. Step 3: Reference 2 faults, evicting 7 and giving [6,1,2]. Next 7 faults, evicting 6 and giving [1,2,7]. Final 2 hits and gives [1,7,2]. Faults occur at positions 1,2,3,4,8,9: total 6.

Original paper, page 57 · Answer key

Descriptive
Report issue

LRU page-fault trace

Virtual Memory & Paging

Question 21(a), GATE 1993: Four initially empty page frames receive [1, 2, 3, 4, 1, 3, 5, 2, 1, 5, 4, 3, 2, 3]. Identify each page fault under LRU.
Question 21(a), GATE 1993: Four initially empty page frames receive [1, 2, 3, 4, 1, 3, 5, 2, 1, 5, 4, 3, 2, 3]. Identify each page fault under LRU.
Question 21(a), GATE 1993: Four initially empty page frames receive [1, 2, 3, 4, 1, 3, 5, 2, 1, 5, 4, 3, 2, 3]. Identify each page fault under LRU.
Tap to enlarge
Answer & solution

Answer: 9 faults, at reference positions 1,2,3,4,7,8,11,12,13. (no official key was published)

Step through it (16 steps)

The first four distinct references each fault and fill the four frames. On a later miss, evict the oldest entry in the policy order below. For LRU that means least recently used; for FIFO it means earliest loaded. LRU moves a referenced resident page to most-recent position even on a hit. Thus after references 5 and 6 the order is 2,4,1,3, and page 2 is evicted for page 5 at reference 7.

The full trace lists reference position, requested page, result, and policy order from eviction candidate to newest:
1: page 1, fault, order 1
2: page 2, fault, order 1,2
3: page 3, fault, order 1,2,3
4: page 4, fault, order 1,2,3,4
5: page 1, hit, order 2,3,4,1
6: page 3, hit, order 2,4,1,3
7: page 5, fault, order 4,1,3,5
8: page 2, fault, order 1,3,5,2
9: page 1, hit, order 3,5,2,1
10: page 5, hit, order 3,2,1,5
11: page 4, fault, order 2,1,5,4
12: page 3, fault, order 1,5,4,3
13: page 2, fault, order 5,4,3,2
14: page 3, hit, order 5,4,2,3

There are 9 faults. Positions are reported rather than only page values because the same page can fault more than once. Initially empty frames cause compulsory faults too; omitting them would undercount.

Original paper, page 13