All task switching is done in software.
[reactos.git] / reactos / ntoskrnl / ex / fmutex.c
1 /* $Id: fmutex.c,v 1.8 2000/12/23 02:37:39 dwelch 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 FASTCALL EXPORTED
22 ExAcquireFastMutexUnsafe (PFAST_MUTEX FastMutex)
23 {
24 if (InterlockedDecrement(&FastMutex->Count) == 0)
25 {
26 return;
27 }
28 FastMutex->Contention++;
29 KeWaitForSingleObject(&FastMutex->Event,
30 Executive,
31 KernelMode,
32 FALSE,
33 NULL);
34 FastMutex->Owner = KeGetCurrentThread();
35 }
36
37 VOID FASTCALL EXPORTED
38 ExReleaseFastMutexUnsafe (PFAST_MUTEX FastMutex)
39 {
40 assert(FastMutex->Owner == KeGetCurrentThread());
41 if (InterlockedIncrement(&FastMutex->Count) <= 0)
42 {
43 return;
44 }
45 FastMutex->Owner = NULL;
46 KeSetEvent(&FastMutex->Event, 0, FALSE);
47 }
48
49 /* EOF */