Hi Dr Teo,
I am confuse regarding the tag in cache and virtual memory paging and would to clarify
For the tag,
if for 8block of main memory is mapped to one block of cache, the tag bit will be calculated as log2(8) = 3bit? So the tag is 3bits? and the offset will mean which block of data in the cache is needed?
[Jason] Tag is 3 bits, as you said. Offset is used to find the particular data in the identified block.
For the virtual memory if we use a system with a virtual address space of 8k and a physcial address of 4k, the page will be log2(8000) = 12.96 = 13bits, so each page will have 13 bits. The offset will be log2(1000) = 9.96 = 10bits so there will be 3pages. The physcial address frame only has 2 frame is it because that the memory it has is log2(4000) = 11.96=12bits. And since the page need 1kbye(2^10), it will left only 2 bits for the frame?
[Jason] As I said before, please treat cache and virtual memory separately. If the virtual memory has 8K locations, it will need 13 bits for each virtual memory address location. It is important to know the size of a page. If each page is 1KB, and the virtual memory is 8KB, there will be 8 pages. The virtual memory is made up of main memory plus a portion of the hard disk. If the main memory is 2 KB, there would be two pages in the main memory. For ease of identification, we call a page in the main memory as a frame. The frame size is same as page size. 2 of the 8 pages would be in the main memory. But, specifically which 2 pages? The page allocation table provides the information. If a page is in the main memory, it would be assigned a frame number, and a valid bit is set in the page table. If a page is not in the main memory, and the CPU needs to access that page, then a page fault occurs. The page is retrieved from hard disk, brought into main memory, assigned a frame number (replace old frame), and valid bit is set. The assigned frame number needs not be in running order.
Thanks
With Regards
Kerk Kok Hui