2008-03-09 14:11:42 +00:00
|
|
|
/*
|
2005-01-26 13:58:37 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2000-07-04 08:52:47 +00:00
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: ntoskrnl/mm/wset.c
|
|
|
|
* PURPOSE: Manages working sets
|
2005-05-09 01:38:29 +00:00
|
|
|
*
|
2005-01-26 13:58:37 +00:00
|
|
|
* PROGRAMMERS: David Welch (welch@cwcom.net)
|
2000-07-04 08:52:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2004-08-15 16:39:12 +00:00
|
|
|
#include <ntoskrnl.h>
|
2001-12-31 01:53:46 +00:00
|
|
|
#define NDEBUG
|
2000-07-04 08:52:47 +00:00
|
|
|
#include <internal/debug.h>
|
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2001-12-31 01:53:46 +00:00
|
|
|
NTSTATUS
|
|
|
|
MmTrimUserMemory(ULONG Target, ULONG Priority, PULONG NrFreedPages)
|
2001-03-25 03:34:30 +00:00
|
|
|
{
|
2004-08-01 07:24:59 +00:00
|
|
|
PFN_TYPE CurrentPage;
|
|
|
|
PFN_TYPE NextPage;
|
2004-04-10 22:36:07 +00:00
|
|
|
NTSTATUS Status;
|
2001-02-06 00:11:20 +00:00
|
|
|
|
2004-04-10 22:36:07 +00:00
|
|
|
(*NrFreedPages) = 0;
|
2001-03-25 03:34:30 +00:00
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
CurrentPage = MmGetLRUFirstUserPage();
|
|
|
|
while (CurrentPage != 0 && Target > 0)
|
2004-04-10 22:36:07 +00:00
|
|
|
{
|
2004-08-01 07:24:59 +00:00
|
|
|
NextPage = MmGetLRUNextUserPage(CurrentPage);
|
2001-12-31 01:53:46 +00:00
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
Status = MmPageOutPhysicalAddress(CurrentPage);
|
2001-12-31 01:53:46 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
2004-04-10 22:36:07 +00:00
|
|
|
{
|
|
|
|
DPRINT("Succeeded\n");
|
|
|
|
Target--;
|
|
|
|
(*NrFreedPages)++;
|
|
|
|
}
|
2003-07-12 01:52:10 +00:00
|
|
|
else if (Status == STATUS_PAGEFILE_QUOTA)
|
2004-04-10 22:36:07 +00:00
|
|
|
{
|
2008-03-13 15:26:17 +00:00
|
|
|
MmRemoveLRUUserPage(CurrentPage);
|
|
|
|
MmInsertLRULastUserPage(CurrentPage);
|
2004-04-10 22:36:07 +00:00
|
|
|
}
|
2001-03-18 21:28:30 +00:00
|
|
|
|
2004-08-01 07:24:59 +00:00
|
|
|
CurrentPage = NextPage;
|
2004-04-10 22:36:07 +00:00
|
|
|
}
|
|
|
|
return(STATUS_SUCCESS);
|
2000-07-04 08:52:47 +00:00
|
|
|
}
|
2004-07-17 03:03:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
ULONG
|
|
|
|
STDCALL
|
|
|
|
MmTrimAllSystemPagableMemory (
|
|
|
|
IN ULONG PurgeTransitionList
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return 0;
|
|
|
|
}
|