neel roy
neel roy

Reputation: 147

Windows Memory Workings - page tables, and data

I was trying to understand following:

Upvotes: 1

Views: 1705

Answers (2)

valdo
valdo

Reputation: 12943

You are actually asking two questions here.

  1. What's the paging policy regarding the page tables.
  2. What's the paging policy for "writable data" pages (i.e. virtual memory with R/W permissions).

First I'll correct you a little.

Given the fact that lower 2 GB area is reserved for windows, it would make sense that windows would keep page tables for all processes on the system

To be exact it's the upper 2GB that are reserved to windows, more correctly - may be accessed in the kernel mode only by Windows kernel and drivers.

Now, this may surprise you, but the kernel memory may be pagable too! So technically it's not important at all which portion of the 32-bit address space is visible in the user/kernel mode. It's not related to paging.

Another correction: virtual memory may be in physical memory and saved to the page file. There's a common belief that the OS frees physical storage by on-demand saving the pages to the page file. Wrong.

Actually Windows saves memory pages to the page file before they need to be freed. In fact it dumps all the memory pages to the page file (besides of those that are related to other files, such as mapped sections) in background. There are two reasons for this:

  • During high load the OS will free memory pages quicker (since they're already saved)
  • In the kernel mode paging is not always possible. Drivers that run on high IRQL (i.e. serve the most time-critical events) may not access physical storage drivers, hence paging is not possible.

So, the answers to your questions are:

  1. Don't know for sure, but it depends on the OS implementation details. I see no reasons why per-process page table may not be paged-out. It's needed during the context switch and modifying process virtual memory. Both situations don't belong to the time-critical events.
  2. Definitely "writable data" memory pages are saved to the page file. Are they removed from the physical memory? On-demand only, during the system load, in the least-recent-used order.

Upvotes: 0

snoone
snoone

Reputation: 5489

I was wondering whether page tables for inactive process are moved to page file at any point of time?

Yes, page tables are pageable.

Will windows keep all the data pages for all the process in memory or move them to page file at some point.

As far as the Windows paging policy is concerned, there's two kinds of memory: pageable and non-pageable. It doesn't really matter which process it belongs to or even if it belongs to the O/S itself, if it's pageable then it's subject to being paged out. So, yes, Windows will page out process data pages if necessary.

I suggest reading the memory management chapter in the Windows Internals book, it should cover all of this.

-scott

Upvotes: 1

Related Questions