3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ex/fmutex.c
6 * PURPOSE: Implements fast mutexes
8 * PROGRAMMERS: David Welch (welch@cwcom.net)
11 /* INCLUDES *****************************************************************/
14 #include <internal/debug.h>
16 /* FUNCTIONS *****************************************************************/
22 ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex
)
24 ASSERT(FastMutex
->Owner
!= KeGetCurrentThread());
25 InterlockedIncrementUL(&FastMutex
->Contention
);
26 while (InterlockedExchange(&FastMutex
->Count
, 0) == 0)
28 KeWaitForSingleObject(&FastMutex
->Event
,
34 InterlockedDecrementUL(&FastMutex
->Contention
);
35 FastMutex
->Owner
= KeGetCurrentThread();
42 ExReleaseFastMutexUnsafe(PFAST_MUTEX FastMutex
)
44 ASSERT(FastMutex
->Owner
== KeGetCurrentThread());
45 FastMutex
->Owner
= NULL
;
46 InterlockedExchange(&FastMutex
->Count
, 1);
47 if (FastMutex
->Contention
> 0)
49 KeSetEvent(&FastMutex
->Event
, 0, FALSE
);