With a 2^32 address space and 4K ( 2^12 ) page sizes, this leave 2^20 entries in the page table. At 4 bytes per entry, this amounts to a 4 MB page table, which is too large to reasonably keep in contiguous memory. ( And to swap in and out of memory with each process switch. ) Note that with 4K pages, this would take 1024 pages just to hold the page table!

Please explain me how they are calculating 1024 pages at the end? what is 4bytes per entry in this? Thanks in advance.

Unless you are running a REALLY old computer a 4MB page table can easly fit in contiguous memory, and most modern operating systems will reserve such on boot.

The memory is measured in bytes.
1k bytes are 1024 bytes (not 1000 bytes). This is because the memory space is expresed in powers of two:

2^0=1
2^1=2
2^2=4
2^3=8
2^4=16
2^5=32
2^6=64
2^7=128
2^8=256
2^9=512
2^10=1024 <--- This is why 1k of memory has 1024 bytes.
2^11=2048
2^12=4096 <--- In your problem, one page of memory is 4k with 4096 bytes.

1kB = 1024 bytes
1MB = 1k x 1k memory = 1024x1024 = 1048576 bytes.
1GB 0 1M x 1k = 1k x 1k x 1k = 1024x1024x1024 = 1073741824 bytes

In the rest (of your live):
"k" means 1024
"M" means 1024 x 1024 = 1048576
"G" means 1024 x 1024 x 1024 = 1073741824

4kB = 4x1024 = 4096 bytes is one page of memory.

2^32 has 4294967296 bytes is your total space for your table.

2^32/1024 = 4194304 k bytes = 4194304x1024.
2^32/1024/1024 = 4096 M bytes = 4096x1024x1024.
2^32/1024/1024/1024 = 4GB = 4 x 1024 x 1024 x 1024.

That is: you have 4GB of total space memory. (The question is wrong because it says 4MB and must say 4GB).

2^32/1024/4 = 2^32/4096 = 1048576 pages of memory.

2^20 = 1048576. That is, you have 2^20 pages of memory.

2^20 = 1048576 = 1024x1024. That is you have 1024 k pages of memory.

You have 1M pages of memory and each page has 4k bytes.

If one entry uses 4 bytes, you have 4096/4 = 1024 entries per memory page.
So, you have 1k entries per page.

With all of this numbers, I think the problem is wrong formulated. It must say something like:

With a 2^32 address space and 4K (2^12) page sizes, this leave 2^20 pages in the table. At 4 bytes per entry, this amounts to a 4 GB page table, which is too large to reasonably keep in contiguous memory. (And to swap in and out of memory with each process switch.) Note that with 4K page sizes, this would take 1024 k pages (=1M pages) just to hold the total table!

I marked in bold the modifications. Hope to help.

@Maritimo I think you are wrong in your explanation when you are making my statement corerct. I think statement written by me was correct. How comes 4Gb thing? Please explain.

The page table has 2^20 entries. Each entry takes 4 bytes. So the page table is 4*(2^20) bytes in total.

You can write 2^12 bytes on a page. So how many pages do you need to write out the entire page table?

(size of page table) / (bytes per page) =

(4*2^20) / ( 2^12) =

2^10 = 1024 pages

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.