Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider a 2-way set associative cache memory... Start Learning for Free
Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55 
  • a)
    0 3 5 7 16 55
  • b)
    0 3 5 7 9 16 55
  • c)
    0 5 7 9 16 55
  • d)
    3 5 7 9 16 55
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
Consider a 2-way set associative cache memory with 4 sets and total 8 ...
2-way set associative cache memory, .i.e K = 2.

No of sets is given as 4, i.e. S = 4 ( numbered 0 - 3 )

No of blocks in cache memory is given as 8, i.e. N =8 ( numbered from 0 -7)

Each set in cache memory contains 2 blocks.

The number of blocks in the main memory is 128, i.e  M = 128.  ( numbered from 0 -127)
A referred block numbered X of the main memory is placed in the  set numbered ( X mod S ) of the the cache memory. In that set, the 
block can be placed at any location, but if the set has already become full, then the current referred block of the main memory should replace  a block in that set according to some replacement policy. Here the replacement policy is LRU ( i.e. Least Recently Used block should  be replaced with currently referred block).

X ( Referred block no ) and 
the corresponding Set values are as follows:

X-->set no ( X mod 4 )

0--->0   ( block 0 is placed in set 0, set 0 has 2 empty block locations,
              block 0 is placed in any one of them  )

5--->1   ( block 5 is placed in set 1, set 1 has 2 empty block locations,
              block 5 is placed in any one of them  )

3--->3  ( block 3 is placed in set 3, set 3 has 2 empty block locations,
             block 3 is placed in any one of them  )

9--->1  ( block 9 is placed in set 1, set 1 has currently 1 empty block location,
             block 9 is placed in that, now set 1 is full, and block 5 is the 
             least recently used block  )

7--->3  ( block 7 is placed in set 3, set 3 has 1 empty block location, 
             block 7 is placed in that, set 3 is full now, 
             and block 3 is the least recently used block)

0--->block 0 is referred again, and it is present in the cache memory in set 0,
            so no need to put again this block into the cache memory.

16--->0  ( block 16 is placed in set 0, set 0 has 1 empty block location, 
              block 0 is placed in that, set 0 is full now, and block 0 is the LRU one)

55--->3 ( block 55 should be placed in set 3, but set 3 is full with block 3 and 7, 
             hence need to replace one block with block 55, as block 3 is the least 
             recently used block in the set 3, it is replaced with block 55.
Hence the main memory blocks present in the cache memory are : 0, 5, 7, 9, 16, 55 .

(Note: block 3 is not present in the cache memory, it was replaced with block 55 )
View all questions of this test
Most Upvoted Answer
Consider a 2-way set associative cache memory with 4 sets and total 8 ...
Cache Memory Configuration:
- 2-way set associative cache memory
- 4 sets
- Total 8 cache blocks (0-7)

Main Memory Configuration:
- 128 blocks (0-127)

Cache Replacement Policy:
- Least Recently Used (LRU)

Memory Block References:
0 5 3 9 7 0 16 55

Explanation:

Step 1: Cache Initialization
- Initially, the cache is empty and does not have any memory blocks from the current job.

Step 2: Memory Block 0
- Memory block 0 is referenced.
- As the cache is empty, memory block 0 will be loaded into an available cache block.
- The cache will look like:
- Set 0: Block 0
- Set 1: Empty
- Set 2: Empty
- Set 3: Empty

Step 3: Memory Block 5
- Memory block 5 is referenced.
- As the cache is 2-way set associative, it can hold 2 memory blocks per set.
- Both cache blocks in Set 1 are empty, so memory block 5 will be loaded into an empty cache block in Set 1.
- The cache will look like:
- Set 0: Block 0
- Set 1: Block 5
- Set 2: Empty
- Set 3: Empty

Step 4: Memory Block 3
- Memory block 3 is referenced.
- As the cache is 2-way set associative, it can hold 2 memory blocks per set.
- Both cache blocks in Set 0 are empty, so memory block 3 will be loaded into an empty cache block in Set 0.
- The cache will look like:
- Set 0: Block 3, Block 0
- Set 1: Block 5
- Set 2: Empty
- Set 3: Empty

Step 5: Memory Block 9
- Memory block 9 is referenced.
- As the cache is 2-way set associative, it can hold 2 memory blocks per set.
- Both cache blocks in Set 2 are empty, so memory block 9 will be loaded into an empty cache block in Set 2.
- The cache will look like:
- Set 0: Block 3, Block 0
- Set 1: Block 5
- Set 2: Block 9
- Set 3: Empty

Step 6: Memory Block 7
- Memory block 7 is referenced.
- As the cache is 2-way set associative, it can hold 2 memory blocks per set.
- Both cache blocks in Set 3 are empty, so memory block 7 will be loaded into an empty cache block in Set 3.
- The cache will look like:
- Set 0: Block 3, Block 0
- Set 1: Block 5
- Set 2: Block 9
- Set 3: Block 7

Step 7: Memory Block 0
- Memory block 0 is
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer?
Question Description
Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer?.
Solutions for Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer?, a detailed solution for Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55a)0 3 5 7 16 55b)0 3 5 7 9 16 55c)0 5 7 9 16 55d)3 5 7 9 16 55Correct answer is option 'C'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
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