Discussion:
KeEnterCriticalRegion vs APC_LEVEL
(too old to reply)
Alex
2004-02-11 17:43:26 UTC
Permalink
What is difference between using KeEnterCriticalRegion and raising IRQL to
APC_LEVEL? As I know, KeEnterCriticalRegion disables only normal kernel apc
but raising to APC_LEVEL disables a special kernel apc too. Is it true?
But I doubt about what type of apc disabling mechanism I should use in
various cases. In what case I should simply call to KeEnterCriticalRegion
and in what case I should raise to APC_LEVEL? In other words, when I must
raise IRQL to APC_LEVEL instead of call to KeEnterCriticalRegion to prevent
possibly deadlocks?

Tanks for assistance.
Neill Clift [MS]
2004-02-11 23:27:22 UTC
Permalink
Post by Alex
What is difference between using KeEnterCriticalRegion and raising IRQL to
APC_LEVEL? As I know, KeEnterCriticalRegion disables only normal kernel apc
but raising to APC_LEVEL disables a special kernel apc too. Is it true?
Yes. KeEnterCriticalRegion and FsRtlEnterFilesystem both just block kernel
APC's.
Post by Alex
But I doubt about what type of apc disabling mechanism I should use in
various cases. In what case I should simply call to KeEnterCriticalRegion
and in what case I should raise to APC_LEVEL? In other words, when I must
raise IRQL to APC_LEVEL instead of call to KeEnterCriticalRegion to prevent
possibly deadlocks?
Tanks for assistance.
The reason to block APC's is to prevent deadlocks. For example if you don't
disable
any APC's when you acquire a lock you might deadlock if an APC files in your
thread
and you attempt to obtain that same lock. So to answer the question you
posed you need
to know all the environments you would obtain your lock etc. For example
special kernel
APC's run code for i/o completion and they can take pagefaults. If your code
is in the
paging path then clearly you would need to raise to APC_LEVEL.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Maxim S. Shatskih
2004-02-13 03:46:07 UTC
Permalink
Post by Alex
What is difference between using KeEnterCriticalRegion and raising IRQL to
APC_LEVEL? As I know, KeEnterCriticalRegion disables only normal kernel apc
but raising to APC_LEVEL disables a special kernel apc too. Is it true?
Yes.
Post by Alex
various cases. In what case I should simply call to KeEnterCriticalRegion
Usually, KeEnterCriticalRegion is enough.
Raising to APC_LEVEL will only also block IopCompleteRequest, and thus the
events specified to IoBuildDeviceIoControlRequest and such.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
***@storagecraft.com
http://www.storagecraft.com
Loading...