2004-08-15 Casper S. Hornstrup <chorns@users.sourceforge.net>
[reactos.git] / reactos / ntoskrnl / ke / critical.c
1 /* $Id: critical.c,v 1.10 2004/08/15 16:39:05 chorns Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ke/critical.c
6 * PURPOSE: Implement critical regions
7 * PROGRAMMER: David Welch (welch@mcmail.com)
8 * UPDATE HISTORY:
9 * Created 22/05/98
10 */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ntoskrnl.h>
15 #define NDEBUG
16 #include <internal/debug.h>
17
18 /* FUNCTIONS *****************************************************************/
19
20 /*
21 * @implemented
22 */
23 VOID STDCALL KeEnterCriticalRegion (VOID)
24 {
25 DPRINT("KeEnterCriticalRegion()\n");
26 KeGetCurrentThread()->KernelApcDisable--;
27 }
28
29 /*
30 * @implemented
31 */
32 VOID STDCALL KeLeaveCriticalRegion (VOID)
33 {
34 PKTHREAD Thread = KeGetCurrentThread();
35
36 DPRINT("KeLeaveCriticalRegion()\n");
37
38 /* Reference: http://www.ntfsd.org/archive/ntfsd0104/msg0203.html */
39 if(++Thread->KernelApcDisable == 0)
40 {
41 if (!IsListEmpty(&Thread->ApcState.ApcListHead[KernelMode]))
42 {
43 Thread->ApcState.KernelApcPending = TRUE;
44 HalRequestSoftwareInterrupt(APC_LEVEL);
45 }
46 }
47
48 }
49
50 /* EOF */