ccfdcfd904be40fe15b86a49abc6b0a89bb68046
[reactos.git] / reactos / hal / halx86 / generic / fmutex.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/hal/x86/fmutex.c
6 * PURPOSE: Implements fast mutexes
7 * PROGRAMMER: David Welch (welch@cwcom.net)
8 * Eric Kohl (ekohl@rz-online.de)
9 * UPDATE HISTORY:
10 * Created 09/06/2000
11 */
12
13 /* INCLUDES *****************************************************************/
14
15 #include <hal.h>
16 #define NDEBUG
17 #include <debug.h>
18
19 /* FUNCTIONS *****************************************************************/
20
21 #undef KeEnterCriticalRegion
22 #undef KeLeaveCriticalRegion
23 VOID FASTCALL
24 ExAcquireFastMutex (PFAST_MUTEX FastMutex)
25 {
26 KeEnterCriticalRegion();
27 ExAcquireFastMutexUnsafe(FastMutex);
28 }
29
30
31 VOID FASTCALL
32 ExReleaseFastMutex (PFAST_MUTEX FastMutex)
33 {
34 ExReleaseFastMutexUnsafe(FastMutex);
35 KeLeaveCriticalRegion();
36 }
37
38
39 BOOLEAN FASTCALL
40 ExTryToAcquireFastMutex (PFAST_MUTEX FastMutex)
41 {
42 KeEnterCriticalRegion();
43 if (InterlockedExchange(&FastMutex->Count, 0) == 1)
44 {
45 FastMutex->Owner = KeGetCurrentThread();
46 return(TRUE);
47 }
48 else
49 {
50 KeLeaveCriticalRegion();
51 return(FALSE);
52 }
53 }
54
55 /* EOF */