Both those dedicated thread serve to one purpose only: flush modified page
frames to secondary storage, thus ensuring that always will be a certain
number of page frames available for reuse. Logic says (altough I did not
checked in Windbg) that 2 threads are required because the mapped page
writter, while flushing to sencondary stoarge, can cause page faults,
reclaiming free memory for inpage operations to complete. But if there are
no free pages for satisfying the request, the system would deadlock. the
simpliest design is 2 threads , the mapped page can block whithout any
problem. Again , this is an educated guess,
it was not verified by tracing the code.
The page fault handler uses bit 9 in a hardware PTE (IA32 architecture
,the bit is not CPU architectural, but software “overloaded”) to determine
if it must copy the page before a write. However, the whole COW issue is a
bit more complex, and is managed through other core OS structures as well.
Other usefull bits are
bit 10: PrtotypePte
bit11: Transition Pte
-
The main reasons why a inpage operation have to run at IRQL < DISPATCH is
because the thread must block, waiting for the inpage (brinigng the page
back from secondary storage) operation to complete. Blocking for a non zero
interval at DISPATCH or higher IRQL is imposible. (DISPATCH IRQL is the
level at witch the OS thread dispatcher operates)
The reference count indicates ifany PTE referes to this page in the PFN
database. Valid page frames have a non zero reference count, and this
indicates that the page is activly used. The reference count is decremented
whenever a PTE no longer points to it. When the reference count reach 0,
the page frame is considered no more in use , and is automatically put on
one of 4 different MM lists, which holds unused pages. (bad page list, free
page list, modified page list, and standby page list).
Usualy this is incremented when a page is intially put into the working set,
and later when the page is locked in memory for any purpose, usualy IO. The
reference count is decremented if the ShareCount reach 0, or the page is
beeing unlocked.
If think the share count indicates whatever a process working set references
this. When share count is 0, the page in question is no more owned by a
working set.
Id like Tony Mason to comment a bit on this last point, if he reads this
post, and tell me if Im right here.
----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Monday, June 10, 2002 4:42 PM
Subject: [ntdev] Few basic doubts related to NT internals
> I have following doubts
>
> 1. Why do we have 2 separate threads named “Modified Page writer” and
> “Mapped Page writer” ? I understand that these two threads do two slightly
> separate tasks but why could not we have a single thread doing both the
> tasks ?Afterall, both tasks involved flushing data from volatile physical
> memory to the secondary storage.
>
> 2. Where exactly is the “copy on write flag located”?Is it in the
> represented by some flag in the PFN data structure, or some flag in the
> Page Table Entry (PTE) or in the Virtual Address Descriptor (VAD) ?
>
> 3. Why no page fault is allowed above IRQL_DISPATCH_LEVEL ?
>
> 4. PFN for a page in working set contains two entries named “Reference
> count” and “Share count”.What is the difference in these two?
>
>
> Regards,
> Prashant S
>
> —
> You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> To unsubscribe send a blank email to %%email.unsub%%
>