3
$\begingroup$

A machine has 48-bit virtual addresses and 32-bit physical addresses. Pages are 8K. How many entries are needed for a conventional page table ?

The answer is 2^35 entries

Why not (2^32) / (2^13) = 2^19 entries...?

My doubt here is why does the number of page table entries depend on virtual address space rather than physical address space?

What does it mean to have more virtual address space than physical address space? The process can only access as many pages present in the physical memory. So it makes sense to have same have both virtual and physical memory address space same. But why have more virtual address space? Does it mean 2 different virtual address entries are mapped to the same physical location in the same page table? Guess that would lead to inconsistency right? Can someone help me get the bigger picture here..... I really need to internalize this concept.

$\endgroup$
1
  • 4
    $\begingroup$ The whole point of virtual memory (or, at least, one of them) is to allow processes to use more memory than there is physical memory. $\endgroup$ Jan 30, 2016 at 7:50

3 Answers 3

3
$\begingroup$

When we are using Virtual Memory, we are translating from a Virtual Address Space to a Physical Address Space.

To understand why it requires $2^{35}$ entries, consider the page size. In order to byte address $8$KB, we require $2^{13}$ entries. If we consider the Virtual Address given to us of $48$ bits, this gives us $48-13=35$ bits. These are the bits that are used for indexing into the page table for determining the address of the page or 'frame' in main memory.

The reason for having more virtual memory is because programs were getting so large that they couldn't be fit in main memory. So in order to allow a greater degree of multiprogramming, virtual memory was introduced. A program could have a 'large' memory to itself. However only the required parts would be loaded into memory as and when required a concept refered to as Demand Paging.

$\endgroup$
2
  • $\begingroup$ Hi... But what if the page table contains 2 or more different virtual addresses mapped to the same physical address? How exactly does 48 bit virtual address translate to 32 bit physical address, leaving the page size aside. i.e 35 bit virtual addr. translating to 19 bit physical addr. How? $\endgroup$
    – Ryan sams
    Jan 30, 2016 at 8:29
  • $\begingroup$ I would suggest reading the basics of Paging from an Operating Systems textbook for that question. Your question is pretty much the definition of demand paging. $\endgroup$
    – kauray
    Jan 30, 2016 at 9:27
0
$\begingroup$

Why not (2^32) / (2^13) = 2^19 entries...?

Page table is organized as per number of pages and not frames.

i.e. 2^48/2^13=2^35

But if you are using inverted page table then reverse mapping will be done and table will be organized as per number of frames.

i.e. 2^32/2^13=2^19.

The reason for having more virtual memory

The main objective is to increase the degree of multi programming i. e. ability to interact will multiple processes though we have insufficient amount of physical memory.

$\endgroup$
0
$\begingroup$

As we know |pageAddress|Offset| -> |Virtual Address|.

Pages are 8K i.e 8*1024 = 2^13 bytes.

This implies that it needs 13 bits as offset value . And higher (48-13 = 35) bits for size of page address. So, total 2^35 entries in page table.

Note: if n bit of page address then there are altogether 2^n entries in page Table.


My doubt here is why does the number of page table entries depend on virtual address space rather than physical address space?

Virtual Memory which is divided into fixed sized block is called pages. CPU deals with only virtual address which is not actual memory address and not real exist. The physical memory is divided into number of fixed size block is called page frames and it has physical address.

Every time to access memory content Memory management Unit (MMU) convert virtual address to Physical address.

Visit this link

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.