Virtual address : 0101110101001100 (last 8 bits is offset)
physical address : 110011110001001100 (last 8 bits is offset)
1) How many virtual and physical addresses are there?
2) How many pages and how many page frames are there?
3) Whats the size of the page in bits?
The answers should be fairly easy but I found various solutions and got confused.
1) I assume there are 2^16 virtual addresses and 2^18 physical
2) 2^16 pages but how many page frames?
3) 2^8 bytes or 2^8 bits ?
1) is correct 2^16 VA and 2^18 PA
Pages is the terminology for virtual addresses and page frames for physical addresses.
Offset indicates byte address within a given page (or page frame). The remaining in the address indicates a mean to address a page. And the adresse of any byte is formed by concatenating the address of its page and its address within a page.
If you have 8 bits offset and 16 bits virtual address, a page address is on 8 bits and there are 2^8 pages. Similarly for physical addresses, page frame addresses are on 10 bits and there are 2^10 page frames.
And page or page frame size is 2^8 bytes (addresses always refer to byte).
Related
Say I have:
page size = 2^12 bytes
physical memory = 2^24 bytes
logical address space = 2^32
How many page-table entries are needed in case the program uses the whole logical address space?
I have found so far that the inner offset is 12 bits while the page number part inside the logical address is 20 bits.
Is the answer 2^20 correct?
I am given a system with 64-bit virtual address space. with page size of 2KB.
Also it is given that the physical memory is of the size 16GB.
I need to calculate the following parameters:
number of page entries (number of lines in the page table), how many bits are needed for the page offset, how many bits are needed for the virtual page number (VPN), and how many bits are needed for the physical page number (PPN).
So, first I concluded that the size of the virtual memory is 2^64 bytes, and that means there are 2^53 entries in the page table.
From the size of a page I concluded that 11 bits are needed for the page offset.
From here I'm not so sure.
Since each virtual address is of the size 64 it, then the VPN is of the size 64 - 11 = 53 bits.
Since the physical memory is of the size 2^34 bytes, then a physical address if of 34 bits. Which means the PPN is of the size 34 - 11 = 23 bits.
Are my calculations correct? and also is my thinking correct?
Help would be appreciated
Some of your results are correct. PPN is 23 bits, VPN is 53 bits.
But all the stuff concerning the page tables is wrong.
A page table contains a set of physical page adresses. Hence as a PPN is 23 bits, one needs 4 bytes (the power of 2 above 23) to describe a PP. If pages are 2k bytes, you can store 2^9 PP adresses par page.
As VPN are 53bits, and each table can resolve 9 bits, the translation can be done by 6 consecutive tables.
If you are not familiar with multilevel pages, there are many good tuturials. See for instance https://en.wikipedia.org/wiki/Page_table
What is certain is that the PT size is NOT 2^53!! First because 2^55 is an insane amount of memory (~10^16). And second, because the total number of PP is 2^23, so why use a table 1 billion times larger... (and this is why we use multilevel page tables)
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:
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.
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
I have some problems with understanding, how virtual adress is translated in physical adress on x86-64. Especially, 39-12 bits of PTE describe PFN of physical page. The number of these bits is 28. 12 bits (from 0 to 11) of virtual adress describe the offset in this physical page. To sum up, we have 28 bits (PFN) and 12 bits(offset). Summing we have 40 bits, but physical adress should contain 64 bits, is it so??? Where is error in my reasoning????
64-bit CPUs do not necessarily have a 64-bit address bus. The virtual address space is 64 bits, but the physical address space only has to be large enough to support the largest reasonable amount of RAM.
I can't find a reference at the moment, but 40 bits (one terabyte) sounds about right.
I have been given the format for page table entries:
Bit 23: Valid Bit
Bit 22: Modify Bit
Bits 22-18: LRU Bits
Bits 17-0: Frame Number
Im told that the system uses 32-bit virtual addresses and pages that are 8192 bytes in size.
How could I calculate the maximum amount of physical memory the system can contain?
So you have 18 bits for page numbers. How many possible numbers (and therefore pages) can be represented by 18 bits?
From the above you'll find how many pages there can be. Then each page has 8192 bytes. How many bytes are there in all possible pages?