1 /* $Id: fmutex.c,v 1.8 2000/12/23 02:37:39 dwelch Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ex/fmutex.c
6 * PURPOSE: Implements fast mutexes
7 * PROGRAMMER: David Welch (welch@cwcom.net)
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
16 #include <internal/debug.h>
19 /* FUNCTIONS *****************************************************************/
21 VOID FASTCALL EXPORTED
22 ExAcquireFastMutexUnsafe (PFAST_MUTEX FastMutex
)
24 if (InterlockedDecrement(&FastMutex
->Count
) == 0)
28 FastMutex
->Contention
++;
29 KeWaitForSingleObject(&FastMutex
->Event
,
34 FastMutex
->Owner
= KeGetCurrentThread();
37 VOID FASTCALL EXPORTED
38 ExReleaseFastMutexUnsafe (PFAST_MUTEX FastMutex
)
40 assert(FastMutex
->Owner
== KeGetCurrentThread());
41 if (InterlockedIncrement(&FastMutex
->Count
) <= 0)
45 FastMutex
->Owner
= NULL
;
46 KeSetEvent(&FastMutex
->Event
, 0, FALSE
);