virtual memory

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
szarek
Posts: 14
Joined: Thu Sep 04, 2014 9:27 am

virtual memory

Post by szarek »

Hi,
I can't understand one thing:
I'm reading that: http://www.jamesmolloy.co.uk/tutorial_h ... aging.html
And I give you the citate from this website:
4MB may seem like a large overhead, and to be fair, it is. If you have 4GB of physical RAM, it's not much. However, if you are working on a machine that has 16MB of RAM, you've just lost a quarter of your available memory! What we want is something progressive, that will take up an amount of space proportionate to the amount of RAM you have.
And now I understand why 4GB physical memory require 4MB for page table.
But, in the citate is written if we have 16 MB physically memory we also need 4MB for page table. Why?
After all, we need to map less memory than 4GB RAM.
I calculate this that:
We have 32-bit entries. Every page is 4KB. So there are 16 * 1024 / 4 = 4096 pages, so the same is number of entries. Every entries is 32bit, so:
4096*32 / 8 / 1024 = 16 KB.
Please help me :)
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: virtual memory

Post by Brendan »

Hi,
szarek wrote:
4MB may seem like a large overhead, and to be fair, it is. If you have 4GB of physical RAM, it's not much. However, if you are working on a machine that has 16MB of RAM, you've just lost a quarter of your available memory! What we want is something progressive, that will take up an amount of space proportionate to the amount of RAM you have.
And now I understand why 4GB physical memory require 4MB for page table.
But, in the citate is written if we have 16 MB physically memory we also need 4MB for page table. Why?
After all, we need to map less memory than 4GB RAM.
So, you're saying that you "want something progressive, that will take up an amount of space proportionate to the amount of RAM you have"?
szarek wrote:I calculate this that:
We have 32-bit entries. Every page is 4KB. So there are 16 * 1024 / 4 = 4096 pages, so the same is number of entries. Every entries is 32bit, so:
4096*32 / 8 / 1024 = 16 KB.
I estimate that your kernel will only need to use 8 MiB RAM (where the other 8 MiB is left for applications/processes to use). I calculate that you'd only need 8 KiB for page tables in that case (not 16 KiB)... ;)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
mallard
Member
Member
Posts: 280
Joined: Tue May 13, 2014 3:02 am
Location: Private, UK

Re: virtual memory

Post by mallard »

Imagine that, for some reason, you map the first 4KB of every 4MB block of virtual memory. That would take up 4MB of physical memory, but you'd need to have a page table for every 4MB block, taking up another 4MB.

Thus, the amount of memory required for page tables isn't just influenced by how much memory is mapped, but also how spread out it is, so the maximum amount of memory needed for page tables is always 4MB, no matter how much physical memory you actually have.
Image
Post Reply