What is page table entry size?
Asked Answered
R

9

18

I found this example.

Consider a system with a 32-bit logical address space. If the page size in such a system is 4 KB (2^12), then a page table may consist of up to 1 million entries (2^32/2^12). Assuming that each entry consists of 4 bytes, each process may need up to 4 MB of physical address space for the page table alone.

What is the meaning of each entry consists of 4 bytes and why each process may need up to 4 MB of physical address space for the page table?

Rollie answered 11/4, 2014 at 16:5 Comment(1)
Possible duplicate of Calculating Page Table SizeAdamandeve
F
12

A page table is a table of conversions from virtual to physical addresses that the OS uses to artificially increase the total amount of main memory available in a system.

Physical memory is the actual bits located at addresses in memory (DRAM), while virtual memory is where the OS "lies" to processes by telling them where it's at, in order to do things like allow for 2^64 bits of address space, despite the fact that 2^32 bits is the most RAM normally used. (2^32 bits is 4 gigabytes, so 2^64 is 16 gb.) Most default page table sizes are 4096 kb for each process, but the number of page table entries can increase if the process needs more process space. Page table sizes can also initially be allocated smaller or larger amounts or memory, it's just that 4 kb is usually the best size for most processes.

Note that a page table is a table of page entries. Both can have different sizes, but page table sizes are most commonly 4096 kb or 4 mb and page table size is increased by adding more entries.

Ferromagnetism answered 11/4, 2014 at 16:16 Comment(3)
> Most default page table sizes are 4096 kb for each process, I think you mean page size instad of page table size, right?Knitter
@陳力 Possibly, this was so long ago I honestly don't remember, haha. I was taking a class on operating systems at the time and haven't really worked on them since.Ferromagnetism
This is answer is very incorrect. 2^64 is not 4 times more than 2^32, but 4billion times moreDecelerate
C
14

As for why a PTE(page table entry) is 4 bytes:

Several answers say it's because the address space is 32 bits and the PTE needs 32 bits to hold the address.

But a PTE doesn't contain the complete address of a byte, only the physical page number. The rest of the bits contain flags or are left unused. It need not be 4 bytes exactly.

Croak answered 9/9, 2018 at 20:19 Comment(0)
F
12

A page table is a table of conversions from virtual to physical addresses that the OS uses to artificially increase the total amount of main memory available in a system.

Physical memory is the actual bits located at addresses in memory (DRAM), while virtual memory is where the OS "lies" to processes by telling them where it's at, in order to do things like allow for 2^64 bits of address space, despite the fact that 2^32 bits is the most RAM normally used. (2^32 bits is 4 gigabytes, so 2^64 is 16 gb.) Most default page table sizes are 4096 kb for each process, but the number of page table entries can increase if the process needs more process space. Page table sizes can also initially be allocated smaller or larger amounts or memory, it's just that 4 kb is usually the best size for most processes.

Note that a page table is a table of page entries. Both can have different sizes, but page table sizes are most commonly 4096 kb or 4 mb and page table size is increased by adding more entries.

Ferromagnetism answered 11/4, 2014 at 16:16 Comment(3)
> Most default page table sizes are 4096 kb for each process, I think you mean page size instad of page table size, right?Knitter
@陳力 Possibly, this was so long ago I honestly don't remember, haha. I was taking a class on operating systems at the time and haven't really worked on them since.Ferromagnetism
This is answer is very incorrect. 2^64 is not 4 times more than 2^32, but 4billion times moreDecelerate
C
4

1) Because 4 bytes (32 bits) is exactly the right amount of space to hold any address in a 32-bit address space.

2) Because 1 million entries of 4 bytes each makes 4MB.

Cassaundracassava answered 11/4, 2014 at 16:16 Comment(0)
A
4
  1. Your first doubt is in the line, "Each entry in the Page Table Entry, also called PTE, consists of 4 bytes". To understand this, first let's discuss what does page table contain?", Answer will be PTEs. So,this 4 bytes is the size of each PTE which consist of virtual address, offset,( And maybe 1-2 other fields if are required/desired)

  2. So, now you know what page table contains, you can easily calculate the memory space it will take, that is: Total no. of PTEs times the size of a PTE. Which will be: 1m * 4 bytes= 4MB Hope this clears your doubt. :)

Approval answered 22/4, 2015 at 21:14 Comment(0)
A
4

The page table entry is the number number of bits required to get any frame number . for example if you have a physical memory with 2^32 frames , then you would need 32 bits to represent it. These 32 bits are stored in the page table in 4 bytes(32/8) .

Now, since the number of pages are 1 million i.e. so the total size of the page table = page table entry*number of pages =4b*1million =4mb.

hence, 4mb would be required to store store the table in the main memory(physical memory).

Angell answered 1/7, 2016 at 15:7 Comment(0)
E
2

So, the entry refers to page table entry (PTE). The data stored in each entry is the physical memory address (PFN). The underlying assumption here is the physical memory also uses a 32-bit address space. Therefore, PTE will be at least 4 bytes (4 * 8 = 32 bits).

In a 32-bit system with memory page size of 4KB (2^2 * 2^10 B), the maximum number of pages a process could have will be 2^(32-12) = 1M. Each process thinks it has access to all physical memory. In order to translate all 1M virtual memory addresses to physical memory addresses, a process may need to store 1 M PTEs, that is 4MB.

Electrotechnics answered 9/3, 2016 at 21:17 Comment(0)
D
2

Honestly a bit new to this myself, but to keep things short it looks like 4MB comes from the fact that there are 1 million entries (each PTE stores a physical page number, assuming it exists); therefore, 1 million PTE's, which is 2^20 = 1MB. 1MB * 4 Bytes = 4MB, so each process will require that for their page tables.

Debbydebee answered 6/10, 2019 at 18:45 Comment(0)
H
0

size of a page table entry depends upon the number of frames in the physical memory, since this text is from "OPERATING SYSTEM CONCEPTS by GALVIN" it is assumed here that number of pages and frames are same, so assuming the same, we find the number of pages/frames which comes out to be 2^20, since page table only stores the frame number of the respective page, so each page table entry has to be of atleast 20 bits to map 2^20 frame numbers with pages, here 4 byte is taken i.e 32 bits, because they are using the upper limit, since page table not only stores the frame numbers, but it also stores additional bits for protection and security, for eg. valid and invalid bit is also stored in the page table, so to map pages with frames we need only 20 bits, the rest are extra bits to store protection and security information.

Hieronymus answered 2/12, 2021 at 17:45 Comment(0)
T
0

Each entry in the page table (PTE) is a mapping of a virtual address (VA) to a physical address (PA). Instead of a mapping every VA to PA, the operating system maps chunks of virtual address space to physical address space (VA pages to PA frames).

Per the question, the system is a 32-bit logical address space i.e. each VA comprises 32 bits. Since the page size of the system is set to 4kB, the 32-bit VA can be viewed as 20-bit page number + 12-bit page offset.

Thus, there are 2^20 VA pages that need mapping i.e. 1M entries within the page table. The underlying assumption for the system would be that even the PA is 32-bits wide i.e. the system contains 4 GiB of physical RAM. To map a VA page to PA frame, a PTE then needs to be 20-bit frame number + a few permission bits. This would result in each PTE being 32 bits/4 bytes wide. As there 1M such PTEs, the total size of the page table is 4MB.

Tetrastich answered 4/9, 2023 at 16:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.