Virtual memory managers - How do they work?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
smeezekitty
Member
Member
Posts: 50
Joined: Sat Mar 21, 2009 9:42 pm

Virtual memory managers - How do they work?

Post 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?
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Virtual memory managers - How do they work?

Post 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.
smeezekitty
Member
Member
Posts: 50
Joined: Sat Mar 21, 2009 9:42 pm

Re: Virtual memory managers - How do they work?

Post 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.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Virtual memory managers - How do they work?

Post by bluemoon »

Check Intel manuals volume 3 (System Programming). They have full description on how address is translated in different modes.
Post Reply