How is the page size and record count for a page table determined?
What does this operator mean in relation to the operating system?
With a 2 ^ 32 address space and a 4K page size (2 ^ 12), this leaves 2 ^ 20 entries in the page table. At 4 bytes per write, this amounts to 4 Page Table in MB, which is too large to reasonably be kept in contiguous Memories. (And to be swapped and out of memory with each process switch.) Note that with 4K pages it will take 1,024 pages to page table!
Please explain how they calculate 1024 pages at the end? What is 4 bytes per write in this regard? What's the point of 4K page size? 4K means 4 * 1024 bytes? They consider 4 bytes (per word) OR does 4 bytes mean it has 4 * 1024 words, each word is some size, say 4 bytes?
source to share
Please explain to me how they calculate the 1024 pages at the end?
Remember we are dealing with the powers of two, so
4 MB = 4,194,304 bytes
4 KB = 4096 bytes
4 MB / 4 KB
= 4,194,304 Bytes / 4096 Bytes
= 1024 Bytes
What is 4 bytes per write in this regard?
You need 32 bits to refer to all 2 ^ 32 address spaces. 8 bits per byte, 32 bits
= 4 Bytes.
For example, the first address is 0 and the last address is 4294967295 or (2 ^ 32 - 1).
Entry | Page Memory Location
------------------------------------------
1 | 0
2 | 4096
3 | 8192
... | ...
2^20 | 4294963200 -> (2^32 - 1) - 4096
Each entry in the table points to 1 page somewhere in memory. In this example, you can say that it starts from scratch. There will be 2 ^ 20 entries and they will cover the entire memory address range (2 ^ 32). Since each record is 4096 bytes, you only need 2 ^ 20 records to cover all pages.
4K means 4 * 1024 bytes?
Yes, that means each page is 4096 bytes (4 * 1024).
Do they consider 4 bytes (per word), OR 4 bytes means it has 4 * 1024 words, each of which is 4 bytes in size?
It may be smaller on 32-bit processors, but usually a word is 32 bits or 4 bytes.
Add-ons Comments
When I say the page size is 4KB, then it has 1024 entries with 4 bytes each or 1024 * 4 entries with 1 bytes each or what else?
The page can contain anything, it is a data container, which in this example is 4096 bytes. The page table contains records that point to pages . As David said, since the page table is stored in memory, it is also stored in pages.
Someone said the explanation was wrong. Correct option: with a 2 ^ 32 address space and a 4K page size (2 ^ 12), this leaves 2 ^ 20 pages in the table. At 4 bytes per write, this amounts to a 4 GB table , which is too large to reasonably store in contiguous memory. (And to swap in and out of memory with each process switch.) Note that at 4K page sizes, this would take 1,024k pages (= 1M pages) to hold the overall table! Right or Wrong?
He's wrong. If the page table contained data from each page, he would be right. With 4096 byte pages and 2 ^ 20 records, which would be 4,294,967,296 bytes (4GB), but the records were only 4 bytes long. So you multiple that with 2 ^ 20 records to get 4,194,304 bytes (4MB).
source to share
The documentation assumes the following meanings:
2^32 = number of bytes in address space
2^12 = 4K = 4*1024 = number of bytes in one page
2^20 = 1M = 1024*1024 = number of pages
4 = number of bytes in the page table to describe one page
4M = 4*1024*1024 = total number of bytes in the page table
1024 = (4*1024*1024)/(4*1024) = number of pages in the page table
So 4 bytes is 4 bytes (the size of the page table entry for one page, not the size of the page itself!). Yes, 4K means 4 * 1024 bytes, not 4 * 1024 words.
All memory used by the OS and any applications is stored in pages somewhere in the system. Since the page table is what needs to be kept in memory, it is also stored in pages.
source to share