Actually I think Rob’s description is an excellent one!
The one point I would add is the rationale for having “APC_LEVEL” at all.
Specifically, certain operations are required to be performed IN THREAD
CONTEXT. That is because requiring that something be done in thread context
eliminates the “multi-processor” issue since a single thread can only run on
a single processor at one instant in time - it can hop around like a frog on
a hot griddle between instants, but can only be on one at a single instant.
This is a HUGE simplification.
For example, IoQueueThreadIrp (in the Windows XP IFS Kit) relies upon this
when inserting a newly built IRP into the thread’s IRP queue (notice it only
takes the IRP, not the thread AND the IRP? You cannot enqueue to a
DIFFERENT thread!) That is the #1 reason why we have IopCompleteRequest
(the APC used for I/O completion in thread context). We have to get into
process context ANYWAY (to copy data into the right address space) but we
also need to remove this IRP from the thread’s list, which must be done in
thread context (that’s why a mere KeStackAttachProcess is not sufficient to
finish up I/O completion).
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
Hope to see you at the next OSR file systems class October 7, 2002!
-----Original Message-----
From: Fuller, Rob [mailto:xxxxx@inin.com]
Sent: Tuesday, May 21, 2002 11:02 AM
To: File Systems Developers
Subject: [ntfsd] RE: Kernel-mode APC
Tony will probably provide a much more expressive explanation…
The basic idea of disabling normal APC’s is to avoid resource acquisition
deadlock. For example, suppose a thread is performing operations in the
file system with a file system resource acquired exclusively. An APC is
delivered to that thread that interrupts the file system operation. The APC
happens to make another call into the FSD. The FSD tries to acquire the
same file system resource exclusively, and the thread deadlocks. Since
almost every thread in the system tries to do file IO, the system will grind
to a halt.
As you imply in your e-mail, special kernel APC’s are still enabled in order
to allow the IO completion APC’s to run, IopCompleteRequest and friends.
These are an exception because it is known they won’t re-enter the file
system.
-----Original Message-----
From: Leonid Zhigunov [mailto:xxxxx@progate.spb.ru]
Sent: Tuesday, May 21, 2002 9:51 AM
To: File Systems Developers
Subject: [ntfsd] Kernel-mode APC
Hi,
It seems that I do not understand APC mechanism clearly.
For instance, FSDs protect their dispatch routines by
FsRtlEnter/ExitFileSystem(), normal kernel-mode APC should be disabled
before calling ExAcquireResourceXxx(), but I do not understand why.
Could anybody explain me this and/or provide any basic
example, which illustrates when it is necessary to disable
APC and what could happen if it remains enabled?
Thank you for any help.
Kind regards,
Leonid.
You are currently subscribed to ntfsd as: xxxxx@inin.com To unsubscribe
send a blank email to %%email.unsub%%
You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to %%email.unsub%%