Reverted latest changes.
[reactos.git] / reactos / ntoskrnl / mm / pager.c
1 /* $Id: pager.c,v 1.11 2002/09/08 10:23:36 chorns Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/mm/pager.c
6 * PURPOSE: Moves infrequently used data out of memory
7 * PROGRAMMER: David Welch (welch@cwcom.net)
8 * UPDATE HISTORY:
9 * 27/05/98: Created
10 */
11
12 /* INCLUDES ****************************************************************/
13
14 #include <ddk/ntddk.h>
15 #include <internal/ps.h>
16 #include <internal/ke.h>
17 #include <internal/mm.h>
18
19 #define NDEBUG
20 #include <internal/debug.h>
21
22 /* GLOBALS *******************************************************************/
23
24 static HANDLE PagerThreadHandle;
25 static CLIENT_ID PagerThreadId;
26 static KEVENT PagerThreadEvent;
27 static BOOLEAN PagerThreadShouldTerminate;
28
29 /* FUNCTIONS *****************************************************************/
30
31 static NTSTATUS STDCALL
32 MmPagerThreadMain(PVOID Ignored)
33 {
34 NTSTATUS Status;
35
36 for(;;)
37 {
38 Status = KeWaitForSingleObject(&PagerThreadEvent,
39 0,
40 KernelMode,
41 FALSE,
42 NULL);
43 if (!NT_SUCCESS(Status))
44 {
45 DbgPrint("PagerThread: Wait failed\n");
46 KeBugCheck(0);
47 }
48 if (PagerThreadShouldTerminate)
49 {
50 DbgPrint("PagerThread: Terminating\n");
51 return(STATUS_SUCCESS);
52 }
53 }
54 }
55
56 NTSTATUS MmInitPagerThread(VOID)
57 {
58 NTSTATUS Status;
59
60 PagerThreadShouldTerminate = FALSE;
61 KeInitializeEvent(&PagerThreadEvent,
62 SynchronizationEvent,
63 FALSE);
64
65 Status = PsCreateSystemThread(&PagerThreadHandle,
66 THREAD_ALL_ACCESS,
67 NULL,
68 NULL,
69 &PagerThreadId,
70 MmPagerThreadMain,
71 NULL);
72 if (!NT_SUCCESS(Status))
73 {
74 return(Status);
75 }
76
77 return(STATUS_SUCCESS);
78 }