123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071 |
- /*++
- Copyright (c) 2012 Minoca Corp. All Rights Reserved
- Module Name:
- lock.c
- Abstract:
- This module implements common synchronization primitives in the kernel.
- Author:
- Evan Green 6-Aug-2012
- Environment:
- Kernel
- --*/
- //
- // ------------------------------------------------------------------- Includes
- //
- #include <minoca/kernel.h>
- //
- // ---------------------------------------------------------------- Definitions
- //
- #define QUEUED_LOCK_TAG 0x6C51654B // 'lQeK'
- #define SHARED_EXCLUSIVE_LOCK_TAG 0x6553654B // 'eSeK'
- //
- // Define shared exclusive lock states.
- //
- #define SHARED_EXCLUSIVE_LOCK_FREE 0
- #define SHARED_EXCLUSIVE_LOCK_EXCLUSIVE ((ULONG)-1)
- #define SHARED_EXCLUSIVE_LOCK_MAX_WAITERS ((ULONG)-2)
- //
- // ----------------------------------------------- Internal Function Prototypes
- //
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // Queued lock directory where all queued locks are stored. This is primarily
- // done to keep the root directory tidy.
- //
- POBJECT_HEADER KeQueuedLockDirectory = NULL;
- //
- // ------------------------------------------------------------------ Functions
- //
- KERNEL_API
- PQUEUED_LOCK
- KeCreateQueuedLock (
- VOID
- )
- /*++
- Routine Description:
- This routine creates a new queued lock under the current thread. These locks
- can be used at up to dispatch level if non-paged memory is used.
- Arguments:
- None.
- Return Value:
- Returns a pointer to the new lock on success.
- NULL on failure.
- --*/
- {
- PQUEUED_LOCK NewLock;
- POBJECT_HEADER NewObject;
- NewObject = ObCreateObject(ObjectQueuedLock,
- KeQueuedLockDirectory,
- NULL,
- 0,
- sizeof(QUEUED_LOCK),
- NULL,
- 0,
- QUEUED_LOCK_TAG);
- NewLock = (PQUEUED_LOCK)NewObject;
- if (NewLock != NULL) {
- //
- // Initialize the lock to signal one thread so the first wait acquires
- // it.
- //
- ObSignalObject(NewObject, SignalOptionSignalOne);
- }
- return NewLock;
- }
- KERNEL_API
- VOID
- KeDestroyQueuedLock (
- PQUEUED_LOCK Lock
- )
- /*++
- Routine Description:
- This routine destroys a queued lock by decrementing its reference count.
- Arguments:
- Lock - Supplies a pointer to the queued lock to destroy.
- Return Value:
- None. When the function returns, the lock must not be used again.
- --*/
- {
- ObReleaseReference(&(Lock->Header));
- return;
- }
- KERNEL_API
- VOID
- KeAcquireQueuedLock (
- PQUEUED_LOCK Lock
- )
- /*++
- Routine Description:
- This routine acquires the queued lock. If the lock is held, the thread
- blocks until it becomes available.
- Arguments:
- Lock - Supplies a pointer to the queued lock to acquire.
- Return Value:
- None. When the function returns, the lock will be held.
- --*/
- {
- KSTATUS Status;
- Status = KeAcquireQueuedLockTimed(Lock, WAIT_TIME_INDEFINITE);
- ASSERT(KSUCCESS(Status));
- return;
- }
- KERNEL_API
- KSTATUS
- KeAcquireQueuedLockTimed (
- PQUEUED_LOCK Lock,
- ULONG TimeoutInMilliseconds
- )
- /*++
- Routine Description:
- This routine acquires the queued lock. If the lock is held, the thread
- blocks until it becomes available or the specified timeout expires.
- Arguments:
- Lock - Supplies a pointer to the queued lock to acquire.
- TimeoutInMilliseconds - Supplies the number of milliseconds that the given
- object should be waited on before timing out. Use WAIT_TIME_INDEFINITE
- to wait forever on the object.
- Return Value:
- STATUS_SUCCESS on success.
- STATUS_TIMEOUT if the specified amount of time expired and the lock could
- not be acquired.
- --*/
- {
- KSTATUS Status;
- PKTHREAD Thread;
- Thread = KeGetCurrentThread();
- ASSERT(KeGetRunLevel() <= RunLevelDispatch);
- ASSERT((Lock->OwningThread != Thread) || (Thread == NULL));
- Status = ObWaitOnObject(&(Lock->Header), 0, TimeoutInMilliseconds);
- if (KSUCCESS(Status)) {
- Lock->OwningThread = Thread;
- }
- return Status;
- }
- KERNEL_API
- VOID
- KeReleaseQueuedLock (
- PQUEUED_LOCK Lock
- )
- /*++
- Routine Description:
- This routine releases a queued lock that has been previously acquired.
- Arguments:
- Lock - Supplies a pointer to the queued lock to release.
- Return Value:
- None.
- --*/
- {
- ASSERT(KeGetRunLevel() <= RunLevelDispatch);
- Lock->OwningThread = NULL;
- ObSignalObject(&(Lock->Header), SignalOptionSignalOne);
- return;
- }
- KERNEL_API
- BOOL
- KeTryToAcquireQueuedLock (
- PQUEUED_LOCK Lock
- )
- /*++
- Routine Description:
- This routine attempts to acquire the queued lock. If the lock is busy, it
- does not add this thread to the queue of waiters.
- Arguments:
- Lock - Supplies a pointer to a queued lock.
- Return Value:
- Returns TRUE if the lock was acquired, or FALSE otherwise.
- --*/
- {
- KSTATUS Status;
- ASSERT(KeGetRunLevel() <= RunLevelDispatch);
- Status = ObWaitOnObject(&(Lock->Header), 0, 0);
- if (!KSUCCESS(Status)) {
- return FALSE;
- }
- Lock->OwningThread = KeGetCurrentThread();
- return TRUE;
- }
- KERNEL_API
- BOOL
- KeIsQueuedLockHeld (
- PQUEUED_LOCK Lock
- )
- /*++
- Routine Description:
- This routine determines whether a queued lock is acquired or free.
- Arguments:
- Lock - Supplies a pointer to the queued lock.
- Return Value:
- TRUE if the queued lock is held.
- FALSE if the queued lock is free.
- --*/
- {
- if (Lock->Header.WaitQueue.State == SignaledForOne) {
- return FALSE;
- }
- return TRUE;
- }
- KERNEL_API
- VOID
- KeInitializeSpinLock (
- PKSPIN_LOCK Lock
- )
- /*++
- Routine Description:
- This routine initializes a spinlock.
- Arguments:
- Lock - Supplies a pointer to the lock to initialize.
- Return Value:
- None.
- --*/
- {
- Lock->LockHeld = 0;
- Lock->OwningThread = NULL;
- //
- // This atomic exchange serves as a memory barrier and serializing
- // instruction.
- //
- RtlAtomicExchange32(&(Lock->LockHeld), 0);
- return;
- }
- KERNEL_API
- VOID
- KeAcquireSpinLock (
- PKSPIN_LOCK Lock
- )
- /*++
- Routine Description:
- This routine acquires a kernel spinlock. It must be acquired at or below
- dispatch level. This routine may yield the processor.
- Arguments:
- Lock - Supplies a pointer to the lock to acquire.
- Return Value:
- None.
- --*/
- {
- ULONG LockValue;
- while (TRUE) {
- LockValue = RtlAtomicCompareExchange32(&(Lock->LockHeld), 1, 0);
- if (LockValue == 0) {
- break;
- }
- ArProcessorYield();
- }
- Lock->OwningThread = KeGetCurrentThread();
- return;
- }
- KERNEL_API
- VOID
- KeReleaseSpinLock (
- PKSPIN_LOCK Lock
- )
- /*++
- Routine Description:
- This routine releases a kernel spinlock.
- Arguments:
- Lock - Supplies a pointer to the lock to release.
- Return Value:
- None.
- --*/
- {
- ULONG LockValue;
- //
- // The interlocked version is a serializing instruction, so this avoids
- // unsafe processor and compiler reordering. Simply setting the lock to
- // FALSE is not safe.
- //
- LockValue = RtlAtomicExchange32(&(Lock->LockHeld), 0);
- //
- // Assert if the lock was not held.
- //
- ASSERT(LockValue != 0);
- return;
- }
- KERNEL_API
- BOOL
- KeTryToAcquireSpinLock (
- PKSPIN_LOCK Lock
- )
- /*++
- Routine Description:
- This routine makes one attempt to acquire a spinlock.
- Arguments:
- Lock - Supplies a pointer to the lock to attempt to acquire.
- Return Value:
- TRUE if the lock was acquired.
- FALSE if the lock was not acquired.
- --*/
- {
- ULONG LockValue;
- LockValue = RtlAtomicCompareExchange32(&(Lock->LockHeld), 1, 0);
- if (LockValue == 0) {
- Lock->OwningThread = KeGetCurrentThread();
- return TRUE;
- }
- return FALSE;
- }
- KERNEL_API
- BOOL
- KeIsSpinLockHeld (
- PKSPIN_LOCK Lock
- )
- /*++
- Routine Description:
- This routine determines whether a spin lock is held or free.
- Arguments:
- Lock - Supplies a pointer to the lock to check.
- Return Value:
- TRUE if the lock has been acquired.
- FALSE if the lock is free.
- --*/
- {
- ULONG Held;
- Held = RtlAtomicOr32(&(Lock->LockHeld), 0);
- if (Held != 0) {
- return TRUE;
- }
- return FALSE;
- }
- KERNEL_API
- PSHARED_EXCLUSIVE_LOCK
- KeCreateSharedExclusiveLock (
- VOID
- )
- /*++
- Routine Description:
- This routine creates a shared-exclusive lock.
- Arguments:
- None.
- Return Value:
- Returns a pointer to a shared-exclusive lock on success, or NULL on failure.
- --*/
- {
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock;
- KSTATUS Status;
- SharedExclusiveLock = MmAllocateNonPagedPool(sizeof(SHARED_EXCLUSIVE_LOCK),
- SHARED_EXCLUSIVE_LOCK_TAG);
- if (SharedExclusiveLock == NULL) {
- Status = STATUS_INSUFFICIENT_RESOURCES;
- goto CreateSharedExclusiveLockEnd;
- }
- RtlZeroMemory(SharedExclusiveLock, sizeof(SHARED_EXCLUSIVE_LOCK));
- SharedExclusiveLock->Event = KeCreateEvent(NULL);
- if (SharedExclusiveLock->Event == NULL) {
- Status = STATUS_INSUFFICIENT_RESOURCES;
- goto CreateSharedExclusiveLockEnd;
- }
- KeSignalEvent(SharedExclusiveLock->Event, SignalOptionSignalOne);
- Status = STATUS_SUCCESS;
- CreateSharedExclusiveLockEnd:
- if (!KSUCCESS(Status)) {
- if (SharedExclusiveLock != NULL) {
- KeDestroySharedExclusiveLock(SharedExclusiveLock);
- SharedExclusiveLock = NULL;
- }
- }
- return SharedExclusiveLock;
- }
- KERNEL_API
- VOID
- KeDestroySharedExclusiveLock (
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
- )
- /*++
- Routine Description:
- This routine destroys a shared-exclusive lock.
- Arguments:
- SharedExclusiveLock - Supplies a pointer to a shared-exclusive lock.
- Return Value:
- None.
- --*/
- {
- if (SharedExclusiveLock->Event != NULL) {
- KeDestroyEvent(SharedExclusiveLock->Event);
- }
- MmFreeNonPagedPool(SharedExclusiveLock);
- return;
- }
- KERNEL_API
- VOID
- KeAcquireSharedExclusiveLockShared (
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
- )
- /*++
- Routine Description:
- This routine acquired the given shared-exclusive lock in shared mode.
- Arguments:
- SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
- Return Value:
- None.
- --*/
- {
- ULONG ExclusiveWaiters;
- BOOL IsWaiter;
- ULONG PreviousState;
- ULONG PreviousWaiters;
- ULONG SharedWaiters;
- ULONG State;
- IsWaiter = FALSE;
- while (TRUE) {
- State = SharedExclusiveLock->State;
- ExclusiveWaiters = SharedExclusiveLock->ExclusiveWaiters;
- //
- // If no one is trying to acquire exclusive, or this is not the first
- // time around, try to acquire the lock. The reason subsequent attempts
- // are allowed to try to acquire even with exclusive waiters is that
- // without this, shared acquires may go down indefinitely on a free
- // lock (since they soaked up the "signal for one" and got woken up
- // ahead of the exclusive waiter).
- //
- if (((ExclusiveWaiters == 0) || (IsWaiter != FALSE)) &&
- (State < SHARED_EXCLUSIVE_LOCK_EXCLUSIVE - 1)) {
- PreviousState = State;
- State = RtlAtomicCompareExchange32(&(SharedExclusiveLock->State),
- PreviousState + 1,
- PreviousState);
- if (State == PreviousState) {
- //
- // Let all the blocked reader brethren go if this thread was
- // also blocked.
- //
- if (SharedExclusiveLock->SharedWaiters != 0) {
- KeSignalEvent(SharedExclusiveLock->Event,
- SignalOptionPulse);
- }
- break;
- //
- // The addition got foiled, go try again.
- //
- } else {
- continue;
- }
- }
- //
- // Either someone is trying to get it exclusive, or the attempt to
- // get it shared failed. Become a waiter so that the event will be
- // signaled when the lock is released. Use compare-exchange to avoid
- // overflowing.
- //
- if (IsWaiter == FALSE) {
- SharedWaiters = SharedExclusiveLock->SharedWaiters;
- if (SharedWaiters >= SHARED_EXCLUSIVE_LOCK_MAX_WAITERS) {
- continue;
- }
- PreviousWaiters = RtlAtomicCompareExchange32(
- &(SharedExclusiveLock->SharedWaiters),
- SharedWaiters + 1,
- SharedWaiters);
- if (PreviousWaiters != SharedWaiters) {
- continue;
- }
- IsWaiter = TRUE;
- }
- //
- // Recheck the condition now that the waiter count is incremented, as a
- // release may not have seen any waiters and therefore never signaled
- // the event.
- //
- if ((SharedExclusiveLock->ExclusiveWaiters == 0) &&
- (SharedExclusiveLock->State != SHARED_EXCLUSIVE_LOCK_EXCLUSIVE)) {
- continue;
- }
- KeWaitForEvent(SharedExclusiveLock->Event, FALSE, WAIT_TIME_INDEFINITE);
- }
- //
- // This thread is no longer waiting, away it goes.
- //
- if (IsWaiter != FALSE) {
- PreviousWaiters =
- RtlAtomicAdd32(&(SharedExclusiveLock->SharedWaiters), -1);
- ASSERT(PreviousWaiters != 0);
- }
- return;
- }
- KERNEL_API
- VOID
- KeReleaseSharedExclusiveLockShared (
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
- )
- /*++
- Routine Description:
- This routine releases the given shared-exclusive lock from shared mode.
- Arguments:
- SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
- Return Value:
- None.
- --*/
- {
- ULONG PreviousState;
- PreviousState = RtlAtomicAdd32(&(SharedExclusiveLock->State), -1);
- ASSERT((PreviousState < SHARED_EXCLUSIVE_LOCK_EXCLUSIVE) &&
- (PreviousState != SHARED_EXCLUSIVE_LOCK_FREE));
- //
- // If this was the last reader and there are writers waiting, signal the
- // event.
- //
- if ((PreviousState - 1 == SHARED_EXCLUSIVE_LOCK_FREE) &&
- (SharedExclusiveLock->ExclusiveWaiters != 0)) {
- KeSignalEvent(SharedExclusiveLock->Event, SignalOptionSignalOne);
- }
- return;
- }
- KERNEL_API
- VOID
- KeAcquireSharedExclusiveLockExclusive (
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
- )
- /*++
- Routine Description:
- This routine acquired the given shared-exclusive lock in exclusive mode.
- Arguments:
- SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
- Return Value:
- None.
- --*/
- {
- ULONG CurrentState;
- ULONG ExclusiveWaiters;
- BOOL IsWaiting;
- ULONG PreviousWaiters;
- ULONG State;
- IsWaiting = FALSE;
- while (TRUE) {
- State = RtlAtomicCompareExchange32(&(SharedExclusiveLock->State),
- SHARED_EXCLUSIVE_LOCK_EXCLUSIVE,
- SHARED_EXCLUSIVE_LOCK_FREE);
- if (State == SHARED_EXCLUSIVE_LOCK_FREE) {
- break;
- }
- //
- // Increment the exclusive waiters count to indicate to readers that
- // the event needs to be signaled. Use compare-exchange to avoid
- // overflowing.
- //
- if (IsWaiting == FALSE) {
- ExclusiveWaiters = SharedExclusiveLock->ExclusiveWaiters;
- if (ExclusiveWaiters >= SHARED_EXCLUSIVE_LOCK_MAX_WAITERS) {
- continue;
- }
- PreviousWaiters = RtlAtomicCompareExchange32(
- &(SharedExclusiveLock->ExclusiveWaiters),
- ExclusiveWaiters + 1,
- ExclusiveWaiters);
- if (PreviousWaiters != ExclusiveWaiters) {
- continue;
- }
- IsWaiting = TRUE;
- }
- //
- // Recheck the state now that the exclusive waiters count has been
- // incremented, in case the release didn't see the increment and never
- // signaled the event.
- //
- CurrentState = SharedExclusiveLock->State;
- if (CurrentState == SHARED_EXCLUSIVE_LOCK_FREE) {
- continue;
- }
- KeWaitForEvent(SharedExclusiveLock->Event, FALSE, WAIT_TIME_INDEFINITE);
- }
- //
- // This lucky writer is no longer waiting.
- //
- if (IsWaiting != FALSE) {
- PreviousWaiters =
- RtlAtomicAdd32(&(SharedExclusiveLock->ExclusiveWaiters), -1);
- ASSERT(PreviousWaiters != 0);
- }
- return;
- }
- KERNEL_API
- VOID
- KeReleaseSharedExclusiveLockExclusive (
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
- )
- /*++
- Routine Description:
- This routine releases the given shared-exclusive lock from exclusive mode.
- Arguments:
- SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
- Return Value:
- None.
- --*/
- {
- ASSERT(SharedExclusiveLock->State == SHARED_EXCLUSIVE_LOCK_EXCLUSIVE);
- RtlAtomicExchange32(&(SharedExclusiveLock->State),
- SHARED_EXCLUSIVE_LOCK_FREE);
- if ((SharedExclusiveLock->SharedWaiters != 0) ||
- (SharedExclusiveLock->ExclusiveWaiters != 0)) {
- KeSignalEvent(SharedExclusiveLock->Event, SignalOptionSignalOne);
- }
- return;
- }
- KERNEL_API
- VOID
- KeSharedExclusiveLockConvertToExclusive (
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
- )
- /*++
- Routine Description:
- This routine converts a lock that the caller holds shared into one that
- the caller holds exclusive. This routine will most likely fully release
- and reacquire the lock.
- Arguments:
- SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
- Return Value:
- None.
- --*/
- {
- ULONG State;
- //
- // Try a shortcut in the case that this caller is the only one that has it
- // shared.
- //
- State = RtlAtomicCompareExchange32(&(SharedExclusiveLock->State),
- SHARED_EXCLUSIVE_LOCK_EXCLUSIVE,
- 1);
- ASSERT((State >= 1) && (State < SHARED_EXCLUSIVE_LOCK_EXCLUSIVE));
- //
- // If the fast conversion failed, get in line like everybody else.
- //
- if (State != 1) {
- KeReleaseSharedExclusiveLockShared(SharedExclusiveLock);
- KeAcquireSharedExclusiveLockExclusive(SharedExclusiveLock);
- }
- return;
- }
- KERNEL_API
- BOOL
- KeIsSharedExclusiveLockHeld (
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
- )
- /*++
- Routine Description:
- This routine determines whether a shared-exclusive lock is held or free.
- Arguments:
- SharedExclusiveLock - Supplies a pointer to a shared-exclusive lock.
- Return Value:
- Returns TRUE if the shared-exclusive lock is held, or FALSE if not.
- --*/
- {
- if (SharedExclusiveLock->State != SHARED_EXCLUSIVE_LOCK_FREE) {
- return TRUE;
- }
- return FALSE;
- }
- KERNEL_API
- BOOL
- KeIsSharedExclusiveLockHeldExclusive (
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
- )
- /*++
- Routine Description:
- This routine determines whether a shared-exclusive lock is held exclusively
- or not.
- Arguments:
- SharedExclusiveLock - Supplies a pointer to a shared-exclusive lock.
- Return Value:
- Returns TRUE if the shared-exclusive lock is held exclusively, or FALSE
- otherwise.
- --*/
- {
- if (SharedExclusiveLock->State == SHARED_EXCLUSIVE_LOCK_EXCLUSIVE) {
- return TRUE;
- }
- return FALSE;
- }
- KERNEL_API
- BOOL
- KeIsSharedExclusiveLockHeldShared (
- PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
- )
- /*++
- Routine Description:
- This routine determines whether a shared-exclusive lock is held shared or
- not.
- Arguments:
- SharedExclusiveLock - Supplies a pointer to a shared-exclusive lock.
- Return Value:
- Returns TRUE if the shared-exclusive lock is held shared, or FALSE
- otherwise.
- --*/
- {
- if ((SharedExclusiveLock->State != SHARED_EXCLUSIVE_LOCK_FREE) &&
- (SharedExclusiveLock->State < SHARED_EXCLUSIVE_LOCK_EXCLUSIVE)) {
- return TRUE;
- }
- return FALSE;
- }
- //
- // --------------------------------------------------------- Internal Functions
- //
|