In: Computer Science
Suppose you have a hypothetical machine that has 4 MB of physical memory and a 24-bit address space.
Your hypothetical machine uses paging in a linear page table. Each page holds 512 bytes.
Each page still holds 512 bytes.
Given the following virtual address, partition the bits into a virtual page number and an offset.
0xC3D0E6
In linear page tables, the memory menagement unit(MMU) splits a virtual address into page number and page offset components. The page number is used to index into an array of page table entries.
page number | offset |
phsical memory = 4MB=4 * 220 =222 bytes
given 24 bit address space,
virtual address space = 224 Bytes (Total number of bits in virtual address=24 bits)
page size=512 Bytes =29 Bytes
Number ofpages = virtual address space/(page size) =224/ 29 =215
So page number requies 15 bits.
number of bits in offset = (total no of bits in virtual address) -( number of bits in page number)
=24-15=9 bits
So 24 bit virtual address is divided into as follows
15 bit page number | 9 bit offset |
(C3D0E6)16 = (1100 0011 1101 0000 1110 0110)2
[To convert hex to binary, write 4 bit binary of each hex bit (C-->1100, 3->0011 , D-->1101, 0-->0000 , E-->1110,
6-->0110)]
First 15 bit represents page number , 1100 0011 1101 000 =0x61E8
(110000111101000)2 = ( 110 0001 1110 1000)2 = (61E8)16
(To convert binary to hex, we make group of 4 bits, starting from lsb and write the hex code for each group 1000->8, 1110-->E, 0001-->1, 0110-->6)
last 9 bits represents offset0 1110 0110
(011100110)2 = (0 1110 0110)2 =(0E6)16 =(E6)16
So page number=(110000111101000)2 =(61E8)16 , offset =(011100110)2=(E6)16