GATE Exam  >  GATE Questions  >   Consider a 2-way set associative cache with ... Start Learning for Free
Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:
21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22
If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)
  • a)
    0.2
  • b)
    0.3
Correct answer is between '0.2,0.3'. Can you explain this answer?
Verified Answer
Consider a 2-way set associative cache with total 6 cache blocks and ...
21 mod 3 = 0 → miss
7 mod 3 = 1 → miss
20 mod 3 = 2 → miss
32 mod 3 = 2 → miss
21 mod 3 = 0 → hit
16 mod 3 = 1 → miss
27 mod 3 = 1 → miss
22 mod 3 = 1 → miss
7 mod 3 = 0 → miss
16 mod 3 = 1 → hit
22 mod 3 = 1 → hit
Hit Ratio = Total Hit / Total Reference = 3 / 11 = 0.27
View all questions of this test
Most Upvoted Answer
Consider a 2-way set associative cache with total 6 cache blocks and ...
Given:
- 2-way set associative cache
- Total 6 cache blocks
- Memory block requests: 21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22
- LRU replacement policy

Calculating the Hit Ratio:
To calculate the hit ratio, we need to determine the number of cache hits and cache misses.

1. Initializing the Cache:
- Since it is a 2-way set associative cache, we divide the 6 cache blocks into 3 sets, each set containing 2 cache blocks.
- Initially, all cache blocks are empty.

2. Processing the Memory Block Requests:
- We process the memory block requests one by one and check if the requested block is present in the cache.
- If the requested block is present (cache hit), we update the cache and move the accessed block to the MRU (Most Recently Used) position.
- If the requested block is not present (cache miss), we update the cache by replacing the LRU block with the requested block.

3. Calculating the Hit Ratio:
- The hit ratio is calculated as the ratio of the number of cache hits to the total number of memory block requests.

Cache Status:
Initially, all cache blocks are empty.

Memory Block Request: 21
Cache Status: [empty, empty, empty]
Cache Miss

Memory Block Request: 7
Cache Status: [7, empty, empty]
Cache Miss

Memory Block Request: 20
Cache Status: [7, 20, empty]
Cache Miss

Memory Block Request: 32
Cache Status: [7, 20, 32]
Cache Miss

Memory Block Request: 21
Cache Status: [21, 20, 32]
Cache Miss

Memory Block Request: 16
Cache Status: [21, 16, 32]
Cache Miss

Memory Block Request: 27
Cache Status: [21, 16, 27]
Cache Miss

Memory Block Request: 22
Cache Status: [21, 22, 27]
Cache Miss

Memory Block Request: 7
Cache Status: [7, 22, 27]
Cache Hit

Memory Block Request: 16
Cache Status: [7, 16, 27]
Cache Hit

Memory Block Request: 22
Cache Status: [7, 22, 27]
Cache Hit

Calculating Hit Ratio:
- Total number of memory block requests = 11
- Number of cache hits = 3
- Hit ratio = Number of cache hits / Total number of memory block requests = 3 / 11 = 0.27

Answer:
The hit ratio, when using the LRU replacement policy, is 0.27.
Explore Courses for GATE exam

Similar GATE Doubts

Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer?
Question Description
Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer?.
Solutions for Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer?, a detailed solution for Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer? has been provided alongside types of Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider a 2-way set associative cache with total 6 cache blocks and the following sequence of memory block requests arrived:21, 7, 20, 32, 21, 16, 27, 22, 7, 16, 22If LRU replacement policy is used then the hit ratio will be ________. (Upto 2 decimal places.)a)0.2b)0.3Correct answer is between '0.2,0.3'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev