I'm studying for an operating systems final and the study guide has the following problem:
Problem 1
In a 32-bit machine we subdivide the virtual address into 4 segments as follows:
| 10-bit | 8-bit | 6-bit | 8 bit |
We use a 3-level page table, such that the first 10-bit are for the first level and so on.
What is the page size in such a system?- What is the size of a page table for a process that has 256K of memory starting at address 0?
- What is the size of a page table for a process that has a code segment of 48K starting at address 0x1000000, a data segment of 600K starting at address 0x80000000 and a stack segment of 64K starting at address 0xf0000000 and growing upward (like in the PA-RISC of HP)
And there is an answer provided here:
Solution:
- The page field is 8-bit wide, then the page size is 256 bytes.
- Using the subdivision above, the first level page table points to 1024 2nd level page tables, each pointing to 256 3rd page tables, each containing 64 pages. The program's address space consists of 1024 pages, thus we need we need 16 third-level page tables. Therefore we need 16 entries in a 2nd level page table, and one entry in the first level page table. Therefore the size is: 1024 entries for the first table, 256 entries for the 2nd level page table, and 16 3rd level page table containing 64 entries each. Assuming 2 bytes per entry, the space required is 1024 * 2 + 256 * 2 (one second-level paget table) + 16 * 64 * 2 (16 thirdlevel page tables) = 4608 bytes.
- First, the stack, data and code segments are at addresses that require having 3 page tables entries active in the first level page table. For 64K, you need 256 pages, or 4 third-level page tables. For 600K, you need 2400 pages, or 38 thirdlevel page tables and for 48K you need 192 pages or 3 third-level page tables. Assuming 2 bytes per entry, the space required is 1024 * 2 + 256 * 3 * 2 (3 second-level page tables) + 64 * (38+4+3)* 2 (38 third-level page tables for data segment, 4 for stack and 3 for code segment) = 9344 bytes.
(sic)
My first issue here is in the solution for part 2, where it states that the program's address space consists of 1024 pages. I have no idea how that is being determined, and attempts to work it out or find answers so far have proved fruitless. Is there some equation that would give me that or am I missing something?
I've tried working it out myself but best I can do is evaluate that 256 KB is 2^18 bytes, but I don't understand the relationship between the program's memory use and the number of pages that will be in its address space.
It would also be helpful if someone could explain how I determine the size of a page entry from the given information, or is that just something that if not given has to be assumed to be some value like they do here?
What is the size of a page table for a process that has 256K of memory starting at address 0?
We found in the solution of part 1) that the size of a page is 256 bytes. Therefore, the number of pages for a process consuming 256K of memory is 256K/256 = 1K = 2^10 = 1024
User contributions licensed under CC BY-SA 3.0