Moved some functions into the hal.
[reactos.git] / reactos / ntoskrnl / ex / fmutex.c
1 /* $Id: fmutex.c,v 1.6 2000/06/09 20:02:59 ekohl Exp $
2 *
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)
8 * UPDATE HISTORY:
9 * Created 22/05/98
10 */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ddk/ntddk.h>
15
16 #include <internal/debug.h>
17
18
19 /* FUNCTIONS *****************************************************************/
20
21 VOID
22 FASTCALL
23 EXPORTED
24 ExAcquireFastMutexUnsafe (
25 PFAST_MUTEX FastMutex
26 )
27 {
28 if (InterlockedDecrement(&(FastMutex->Count))==0)
29 {
30 return;
31 }
32 FastMutex->Contention++;
33 KeWaitForSingleObject(&(FastMutex->Event),
34 Executive,
35 KernelMode,
36 FALSE,
37 NULL);
38 FastMutex->Owner=KeGetCurrentThread();
39 }
40
41 VOID
42 FASTCALL
43 EXPORTED
44 ExReleaseFastMutexUnsafe (
45 PFAST_MUTEX FastMutex
46 )
47 {
48 assert(FastMutex->Owner == KeGetCurrentThread());
49 FastMutex->Owner=NULL;
50 if (InterlockedIncrement(&(FastMutex->Count))<=0)
51 {
52 return;
53 }
54 KeSetEvent(&(FastMutex->Event),0,FALSE);
55 }
56
57 /* EOF */