Page 1 of 1

Virtual memory managers - How do they work?

Posted: Thu Jun 02, 2011 5:50 pm
by smeezekitty
Please excuse my ignorance.
Suppose you run an i386 in protected mode with a virtual memory manager kernel such as Linux.
Suppose further that the unlikely condition that the ram is massively fragmented to the point of having 4K block used, 4K block free, 4K block used...etc
If a programs allocates 8K of memory and writes to all of it, how does the CPU know to skip over the used block? I did not think the CPU had a concept of nonlinear memory and I did not know there was a mechanism to intercept memory access other then page faults. How are virtual memory managers implemented?

Re: Virtual memory managers - How do they work?

Posted: Thu Jun 02, 2011 6:06 pm
by bluemoon
smeezekitty wrote:I did not think the CPU had a concept of nonlinear memory
Yes, the CPU designer knows that, and therefore paging.

When paging is enabled, the machine (mostly) operate on linear address (aka logical address space),
an MMU translate that linear address into physical address using page table

For simplicity, we define:

Code: Select all

PhysicalAddress = MMU(LinearAddress);
So for example, It's legal to have MMU(0) = 0 and MMU(4096) = 8192,
In this case physical memory addressed by 0 to 8192 is non-continuous.

Re: Virtual memory managers - How do they work?

Posted: Thu Jun 02, 2011 9:54 pm
by smeezekitty
Ahhh... I see a forgot about the Memory Management Unit #-o
I cannot seem to find technical docs on the programming information and general specs.

Re: Virtual memory managers - How do they work?

Posted: Thu Jun 02, 2011 10:36 pm
by bluemoon
Check Intel manuals volume 3 (System Programming). They have full description on how address is translated in different modes.