ExAcquireFastMutex and KeLowerIrql usage..

Hi,
Why does ExAcquireFastMutex raise the IRQL to APC_LEVEL ?

When ExAcquireFastMutex is called, the IRQL is raised to APC_LEVEL.
Once that happens i will not be able to make use of any function which
must be called at an IRQL < APC_LEVEL. Can we use KeLowerIrql before
calling any such function to a IRQL that was before calling
ExAcquireFastMutex and raise the IRQL back to APC_LEVEL after the
function call.

With Regards
D.Nagarajan.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> Why does ExAcquireFastMutex raise the IRQL to APC_LEVEL ?

To avoid deadlocks if the APC will enter the same code.
Fast mutex is not recursive.

When ExAcquireFastMutex is called, the IRQL is raised to APC_LEVEL.
Once that happens i will not be able to make use of any function which
must be called at an IRQL < APC_LEVEL.

This is by design. You must not call any complex functions while holding a lock.
Place all calls to complex functions (in fact, any calls out of your code) to non-locked regions of code.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi, D.Nagarajan!

When ExAcquireFastMutex is called, the IRQL is raised to >APC_LEVEL. Once
that happens i will not be able to make use of any >function which must be
called at an IRQL < APC_LEVEL. Can we use >KeLowerIrql before calling any such
function to a IRQL that was >before calling ExAcquireFastMutex and raise the
IRQL back to >APC_LEVEL after the function call.

Some functions may be called with raised irql successfully, but it’s may lead
to some problems (often is a page fault in paged memory). If you real need to
use system calls use another synchronization object - ERESOURCE with support
routines like ExTry*, ExIs*… And don’t forget about another sync objects like
semaphores, events. Mutex is one method to guard some part of code, but there
are many others.

Eugene.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> to some problems (often is a page fault in paged memory). If you real need to

use system calls use another synchronization object - ERESOURCE with support
routines like ExTry*, ExIs*… And don’t forget about another sync objects like
semaphores, events. Mutex is one method to guard some part of code, but there
are many others.

Usually, FAST_MUTEX and spinlocks are the best kind of locks.
ERESOURCE is for shared/exclusive semantics.
KMUTEX is recursive - this is rarely needed.

You can also use SynchronizationEvent if you really want to call something complex under the lock, though IMHO this can be tolerated
on rarely executed paths only like socket’s bind().

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

All that ExAcquireFastMutex is really doing is guaranteeing that no APC
will interrupt your code. If you lower IRQL, then you have effectively
released the lock, and that will mean that you data may be trashed.

There are many other locking semantics, discussed by other people who
answered this thread.

  • Jake

-----Original Message-----

Subject: ExAcquireFastMutex and KeLowerIrql usage…
From: xxxxx@yahoo.com
Date: Fri, 11 Jan 2002 2:12:44
X-Message-Number: 4

Hi,
Why does ExAcquireFastMutex raise the IRQL to APC_LEVEL ?

When ExAcquireFastMutex is called, the IRQL is raised to APC_LEVEL.
Once that happens i will not be able to make use of any function which
must be called at an IRQL < APC_LEVEL. Can we use KeLowerIrql before
calling any such function to a IRQL that was before calling
ExAcquireFastMutex and raise the IRQL back to APC_LEVEL after the
function call.

With Regards
D.Nagarajan.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com