# Memory Management Problems

On a system using paging and segmentation, the virtual address space consists of upto 16 segments where each segment can be upto 2^16 bytes long. The hardware pages each segment into 512 byte pages. How many bits in the virtual address specify the following?
a) Segment Number
b) Page Number
c) Offset within page
d) Entire virtual address

Solution:
a) 4
Its given that the virtual address space consists of 16 segments. Hence 4 bits (2^4 = 16) are needed to specify the segment number.

b) 7
Given that 1 segment  = 2^16 bytes long
Also given that 1 page = 512 bytes = 2^9 bytes

Therefore 2^16 / 2^9 = 2^7 pages is there in 1 segment. Hence 7 bits are needed to specify the page number.

c) 9
Given that 1 page = 512 bytes = 2^9 bytes. Therefore to get the offset within a page we need 9 bits.

d) 20
4 + 7 + 9 = 20 bits for entire virtual address.

or we can also explain like this. We have 16 segments and each segments can be 2^16 bytes long. Therefore, Total Virtual Address Space = 16 x 2^16 = 2^4 x 2^16 = 2^20

Taken from

1. 1. 2. 