30.06.2013 Views

Under the Hood of .NET Memory Management - Simple Talk

Under the Hood of .NET Memory Management - Simple Talk

Under the Hood of .NET Memory Management - Simple Talk

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7: The Windows <strong>Memory</strong> Model<br />

It's worth pointing out that each process has its own page directory index, <strong>the</strong> address<br />

<strong>of</strong> which is stored in a specific CPU register so as to be always available when a process<br />

thread is running.<br />

The mechanisms for 64-bit processes and 32-bit processes with physical address<br />

extensions (PAE) are similar, but both involve more deeply nested table structures to<br />

cope with overhead <strong>of</strong> <strong>the</strong> larger address space, and <strong>the</strong> virtual address structure also<br />

differs. However, <strong>the</strong> principle is <strong>the</strong> same so, in <strong>the</strong> interests <strong>of</strong> clarity, I will leave<br />

it <strong>the</strong>re.<br />

Page Table Entry<br />

As you have hopefully deduced from <strong>the</strong> previous sections, <strong>the</strong> page table entry (PTE) is<br />

<strong>the</strong> key piece <strong>of</strong> information in virtual addressing because it holds <strong>the</strong> physical memory<br />

location <strong>of</strong> <strong>the</strong> virtual page. Perhaps even more crucially, it records whe<strong>the</strong>r <strong>the</strong> entry is<br />

valid or not. When valid (i.e. <strong>the</strong> valid bit is set), <strong>the</strong> page is actually loaded in physical<br />

memory. O<strong>the</strong>rwise (i.e. when invalid) <strong>the</strong>re are one <strong>of</strong> several possible problems interfering<br />

with <strong>the</strong> addressing process, <strong>the</strong> least <strong>of</strong> which will require <strong>the</strong> page to be reloaded<br />

from <strong>the</strong> page file.<br />

The PTE also stores some info about page security and usage info, but that's<br />

ano<strong>the</strong>r story.<br />

Page Faults<br />

When access is attempted to a virtual page with a PTE validity bit set to zero, it's called<br />

a page fault. The requested page isn't in physical memory, so something else is going to<br />

have to happen.<br />

208

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!