14

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 :)

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
user2562409
  • 141
  • 1
  • 1
  • 4

4 Answers4

14

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

Rupsingh
  • 1,128
  • 1
  • 18
  • 34
5

Given page size and address references :
best way to Calculate page number and offset,
Suppose, page size of is 1KB and address reference is 256.


Page number = (address reference / page size) = 256/1024 = 0

Offset = (address reference % page size) = (256 % 2014) = 256 


Apply the same procedure for the rest of the address references.
moovon
  • 2,219
  • 1
  • 17
  • 15
0

2^12 => 4096 2^32/2^12 => 2^32/4096 => how many 4K pages are there => how many page table entries we need.

Similar calculation for the physical page table i.e. how many page table entries do we need for the inverted page table.

With the above hint, give the question a shot and let us know what you come up with. Once you learn a bit more in your OS course, you will find out that there are pros and cons in each page table design.

lsk
  • 532
  • 4
  • 5
  • Why do you need to know the physical page table entries for the inverted page table? PS - thx – user2562409 Jul 15 '13 at 05:39
  • For this you need to study some theory on inverted page tables....a quick answer is that inverted page tables are sized proportional to the number of physical pages in the system. The normal (or logical) page table is sized for the entire virtual address space of the process i.e the sized on the number of virtual pages in a process. i.e. Inverted page table: one entry for one physical page; Logical or Virtual page table: one entry for one virtual page. Hope it helps. – lsk Jul 15 '13 at 05:59
0

because page size = frame size = 2^12 number of entries in inverted page table = no of frames so we are calculating no of frames