Determining page numbers and offsets for given addresses

user2562409 picture user2562409 · Jul 15, 2013 · Viewed 32k times · Source

Consider a computer system with a 32-bit logical address and 4KB page size. The system supports up to 512MB of physical memory.

How many entries are there in a conventional single-level page table?

Conventional single-level page table: 2^32 / 2^12 (4000)  = 2^20 = 1,048,576

Why did I have to divide 2^32 / 2^12 to get the answer?

How many entries are there in an inverted page table?

An inverted page table needs as many entries as there are page frames in memory.

Inverted page table: 2^29 (512mb)/ 2^12 (4000) = 2^17 = 131,072

Why did I have to divide 512mb / page size to get the inverted page table entries?

What are the page numbers and offsets for the following address references: a) 30000, b) 256, c) 0xbcf034

a) 30000 in hex: x7530 Page #: x7 = 7 offset: x530 = 1328

b) 256 in hex x100 Page #: x0 = 0 offset: x100 = 256

c) 0xbcf034 Page #: xbcf = 3023 offset: x034 = 22

How do I figure out these page numbers and offsets based on the hex addresses?

I know the answers and but I want to understand WHY and HOW. Can someone please explain in detail :)

Answer

Rupsingh picture Rupsingh · Jun 7, 2016

Why did I have to divide 2^32 / 2^12 to get the answer?

2^32 ==> Total virtual memory size

4KB=2^12 ==> Size of a single page

2^32 / 2^12 =2^20 ==> Total number of pages of virtual memory

So page table will be having 2^20 = 1M entries

How many entries are there in an inverted page table?

2^29=512MB ==> Total physical memory

2^12 = page size = frame size

2^29 / 2^12 =2^17 ==> Total number of frames in physical memory

So inverted page table will be having 2^17 = 128K entries

This fig. may clear your remaining doubts:

enter image description here