A CPU generates $32$-bit virtual addresses. The page size is $4$ KB. The processor has a translation look-aside buffer (TLB) which can hold a total of $128$ page table entries and is $4$-way set associative. The minimum size of the TLB tag is:
@nadeshseen Virtual memory is basically storing the code+data of a running program into main memory as well as in secondary memory(hard disk) instead of storing it fully into main memory(RAM). In this technique, the main memory remains empty so that it could be used to execute many programs simultaneously.
@Nitesh Singh 2 Sorry, I didn't ask the question properly. I know what VM is but in TLB each entry stores the number of bits required to address the physical memory(main memory). My question is, in the above problem instead of virtual addresses, shouldn't it be physical addresses?
Physical Address Space = Main memory Size
Logical Address Space / Virtual Address Space = Process Size
@nadeshseen First of all, It is not accurate to say TLB stores bits required to address main memory, it stores the page table of a process and relevant page table entry in page table says where the part of the process is stored in main memory. Now coming back to your query, since a process size or logical address space could be more than main memory size then some part of the process would be stored in secondary memory, now if we have to execute the part of the process which is not in main memory, then how would we do that?
If we call address in the form of physical address space to fulfil our need, we can never reach to the code which is in secondary memory but if we call it in the form of virtual memory(logical address space) then we can fetch that part of the process also and control unit of CPU replaces the required pages with earlier pages present in the main memory.
@Nitesh Singh 2 If some part of the process is not in main memory then page fault occurs. Now, you have to bring that part of the process in the main memory only then you can service it. You never store the logical address(/virtual address) in the page table, only the number of entries depends on the logical address space. Each entry tells where that frame is stored in the main memory and whether that frame is in the main memory or not using the dirty bit(/modified bit).
Page size of $4KB$. So, offset bits are $12$ bits.
So, remaining bits of virtual address $32 - 12 = 20$ bits will be used for indexing...
Number of sets = 128/4 = 32 (4-way set) => 5 bits.
So, tag bits $= 20 - 5 = 15$ bits.
So, option (C).
@rajat_mahajan this is the how the virtual address will be broken up into:
4KB page defines the offset = 12 bits
32 sets in the TLB defines the set = 5 bits
Remaining 32 - 17 = 15 bits will be used to define tag bits.
here people might not notice u, u can ask as a separate question...
Feedback for next edition (if ever there's...