ERESOURCE acquisition.

MS DDK states that normal kernel APCs must be disabled before calling
ExAcquireResourceExclusiveLite (and such). But I did not find answer to when
I can re-enable APCs. Do I have to have APCs disable for the all time of
holding the resource? Or I can re-enable it immediately after call to
ExAcquireResourceExclusiveLite? What may happen if I disable normal kernel
APCs for a long time?

Yes. You MUST leave them disabled - otherwise you will allow arbitrary
reentrancy into your driver and that can lead to deadlock. That is the
whole reason that you have to have kernel APCs disabled whenever you acquire
kernel mutexes and eresources.

The case you need to consider is “what if Thread 1 is holding lock “A” and
then an APC calls back in and the thread acquires lock “B”? If thread 2
holds lock “B” and then an APC calls back in and acquires lock “A”, then I
will have a deadlock.” Blocking APCs disallows that second (arbitrary) lock
acquisition.

Special kernel APCs do not re-enter the storage stack, so they are allowed
(which is why you have KeEnterCriticalRegion (a/k/a FsRtlEnterFileSystem).)

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: Alexey Logachyov [mailto:xxxxx@vba.com.by]
Sent: Thursday, February 06, 2003 8:35 AM
To: File Systems Developers
Subject: [ntfsd] ERESOURCE acquisition.

MS DDK states that normal kernel APCs must be disabled before calling
ExAcquireResourceExclusiveLite (and such). But I did not find answer to when
I can re-enable APCs. Do I have to have APCs disable for the all time of
holding the resource? Or I can re-enable it immediately after call to
ExAcquireResourceExclusiveLite? What may happen if I disable normal kernel
APCs for a long time?


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> MS DDK states that normal kernel APCs must be disabled before
calling

ExAcquireResourceExclusiveLite (and such). But I did not find answer
to when
I can re-enable APCs. Do I have to have APCs disable for the all
time of
holding the resource?

Yes.

ExAcquireResourceExclusiveLite? What may happen if I disable normal
kernel
APCs for a long time?

This can hinder thread termination and suspends.

Max