Wednesday, July 10, 2013

Explain address mapping using pages.



In virtual memory system the virtual address should be mapped into the physical address. For the ease of such mechanism the physical memory is divided into fixed size groups called blocks. The blocks can be also called as page frames. Similarly, the address space is also divided into groups whose size is equivalent to the size of blocks, known as pages. Whenever a program refers to a page stored in the auxiliary memory, it is loaded in one of the page-frame in the physical memory.
Let us consider address space of 8KB and memory space of 4KB. Then with 1KB block size the system has 8 pages and 4 blocks or page-frames. Possibly, there can be at most 4 pages resided in the physical memory at any instance, so the pages have to be moved back and forth from auxiliary memory whenever a program reference to a page not in the physical memory. Having such condition, address mapping is done such a way that the page is easily available to the program. Address space of 8KB leads to 13-bit virtual address and memory space of 4KB leads to 12 –bit physical address. So the 10 LSB bits are used as line number and 3 MSB bits of virtual address is used as page number. The page number behaves as a table index or table address in the page table and locates an entry in the page table. A presence bit is associated with each entry in the page table which indicates that the current page is in the physical memory or not. Each entry include 3-bit information, 2-bit is used to represent the block number in which the page is resided and 1-bit to indicate its presence. Hence, this 2-bit along with the 10-bit line number gives the 12-bit physical address of the particular block. In this way address mapping is done using pages.

4 comments: