1
votes

If virtual memory has a 32-bit address are there 2^32 entries or is the size of total entries 2^32 bytes? or both?

The reason I ask is because I thought it only meant 2^32 entires.

After doing the following problem I am not sure:

  1. Suppose a machine has 48-bit virtual addresses and 32-bit physical addresses.If pages are 4KiB, how many entries are in the page table if it has only a single level?

Solution: 2^48/2^32 = 2^16 pages.

However, number of entries/size of page != number of pages.

size of total entries/size of page = number of pages.

So, I'm wondering if a 32-bit address means there are 2^32 entries or if total entries equal 2^32 bytes or both.

1
There is no answer to that question given your inputs. The number of page table entries is determined from several factors not given.user3344003

1 Answers

1
votes

Jinan, i think you are confused in linux memory related stuff.

your question for :

If virtual memory has a 32-bit address are there 2^32 entries or is the size of total entries 2^32 bytes? or both?

Page table entries are not depend only virtual address space, page size and physical memory are also need to calculate the entries.

I'm taking your example:-

Suppose a machine has 48-bit virtual addresses and 32-bit physical addresses.If pages are 4KiB, how many entries are in the page table if it has only a single level?

Number of entries in page table will be = 2^36.

A page entry is used to get address of physical memory. Here we assume that single level of Paging is happening. So the resulting page table will contain entries for all the pages of the Virtual address space.

Number of entries in page table = 
                  (virtual address space size)/(page size)  

Virtual address = 48 Bit
Page size is = 12 bit ((2^12) is equal to 4KB).

Using above formula we can say that there will be 2^(48-12) = 2^36 entries in page table.

Size of Page Table

No. of bits required to address the 32bit Physical memory = 32. So there will be 2^(32-12) = 2^20 page frames in the physical memory. And page table needs to store the address of all these 2^20 page frames. Therefore, each page table entry will contain 32 bits address of the page frame.. Since memory is byte addressable. So we take that each page table entry is 32 bits i.e. 4 bytes long.

Size of page table = 
  (total number of page table entries) *(size of a page table entry) 
   = (2^36 *4) = 256GB