Add missing processor architecture cases
[reactos.git] / reactos / ntoskrnl / mm / pager.c
1 /* $Id$
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 *
8 * PROGRAMMERS: David Welch (welch@cwcom.net)
9 */
10
11 /* INCLUDES ****************************************************************/
12
13 #include <ntoskrnl.h>
14 #define NDEBUG
15 #include <internal/debug.h>
16
17 /* GLOBALS *******************************************************************/
18
19 #if 0
20 static HANDLE PagerThreadHandle;
21 static CLIENT_ID PagerThreadId;
22 static KEVENT PagerThreadEvent;
23 static BOOLEAN PagerThreadShouldTerminate;
24 static ULONG PagerThreadWorkCount;
25 #endif
26
27 /* FUNCTIONS *****************************************************************/
28
29 #if 0
30 BOOLEAN
31 MiIsPagerThread(VOID)
32 {
33 return(PsGetCurrentThreadId() == PagerThreadId.UniqueThread);
34 }
35
36 VOID
37 MiStartPagerThread(VOID)
38 {
39 ULONG WasWorking;
40
41 WasWorking = InterlockedIncrement(&PagerThreadWorkCount);
42 if (WasWorking == 1)
43 {
44 KeSetEvent(&PagerThreadEvent, IO_NO_INCREMENT, FALSE);
45 }
46 }
47
48 VOID
49 MiStopPagerThread(VOID)
50 {
51 (VOID)InterlockedDecrement(&PagerThreadWorkCount);
52 }
53
54 static NTSTATUS STDCALL
55 MmPagerThreadMain(PVOID Ignored)
56 {
57 NTSTATUS Status;
58
59 for(;;)
60 {
61 /* Wake for a low memory situation or a terminate request. */
62 Status = KeWaitForSingleObject(&PagerThreadEvent,
63 0,
64 KernelMode,
65 FALSE,
66 NULL);
67 if (!NT_SUCCESS(Status))
68 {
69 DbgPrint("PagerThread: Wait failed\n");
70 KEBUGCHECK(0);
71 }
72 if (PagerThreadShouldTerminate)
73 {
74 DbgPrint("PagerThread: Terminating\n");
75 return(STATUS_SUCCESS);
76 }
77 do
78 {
79 /* Try and make some memory available to the system. */
80 MmRebalanceMemoryConsumers();
81 }
82 while(PagerThreadWorkCount > 0);
83 }
84 }
85
86 NTSTATUS MmInitPagerThread(VOID)
87 {
88 NTSTATUS Status;
89
90 PagerThreadShouldTerminate = FALSE;
91 PagerThreadWorkCount = 0;
92 KeInitializeEvent(&PagerThreadEvent,
93 SynchronizationEvent,
94 FALSE);
95
96 Status = PsCreateSystemThread(&PagerThreadHandle,
97 THREAD_ALL_ACCESS,
98 NULL,
99 NULL,
100 &PagerThreadId,
101 (PKSTART_ROUTINE) MmPagerThreadMain,
102 NULL);
103 if (!NT_SUCCESS(Status))
104 {
105 return(Status);
106 }
107
108 return(STATUS_SUCCESS);
109 }
110 #endif