mirror of
https://github.com/reactos/reactos.git
synced 2024-09-14 14:51:27 +00:00
1. implemented SetProcessWorkingSetSize()
2. fixed Set/GetPriorityClass() not to call csrss and use NtSet/QueryInformationProcess() instead svn path=/trunk/; revision=10921
This commit is contained in:
parent
b912ada645
commit
17cd1043bb
|
@ -5,11 +5,6 @@
|
||||||
#include <ddk/ntddblue.h>
|
#include <ddk/ntddblue.h>
|
||||||
#include <ntos.h>
|
#include <ntos.h>
|
||||||
|
|
||||||
#define CSR_PRIORITY_CLASS_NORMAL (0x10)
|
|
||||||
#define CSR_PRIORITY_CLASS_IDLE (0x20)
|
|
||||||
#define CSR_PRIORITY_CLASS_HIGH (0x40)
|
|
||||||
#define CSR_PRIORITY_CLASS_REALTIME (0x80)
|
|
||||||
|
|
||||||
#define CSR_CSRSS_SECTION_SIZE (65536)
|
#define CSR_CSRSS_SECTION_SIZE (65536)
|
||||||
|
|
||||||
typedef __declspec(noreturn) VOID CALLBACK(*PCONTROLDISPATCHER)(DWORD);
|
typedef __declspec(noreturn) VOID CALLBACK(*PCONTROLDISPATCHER)(DWORD);
|
||||||
|
|
|
@ -5049,16 +5049,16 @@ WINBOOL
|
||||||
STDCALL
|
STDCALL
|
||||||
GetProcessWorkingSetSize(
|
GetProcessWorkingSetSize(
|
||||||
HANDLE hProcess,
|
HANDLE hProcess,
|
||||||
LPDWORD lpMinimumWorkingSetSize,
|
PSIZE_T lpMinimumWorkingSetSize,
|
||||||
LPDWORD lpMaximumWorkingSetSize
|
PSIZE_T lpMaximumWorkingSetSize
|
||||||
);
|
);
|
||||||
|
|
||||||
WINBOOL
|
WINBOOL
|
||||||
STDCALL
|
STDCALL
|
||||||
SetProcessWorkingSetSize(
|
SetProcessWorkingSetSize(
|
||||||
HANDLE hProcess,
|
HANDLE hProcess,
|
||||||
DWORD dwMinimumWorkingSetSize,
|
SIZE_T dwMinimumWorkingSetSize,
|
||||||
DWORD dwMaximumWorkingSetSize
|
SIZE_T dwMaximumWorkingSetSize
|
||||||
);
|
);
|
||||||
|
|
||||||
HANDLE
|
HANDLE
|
||||||
|
|
|
@ -26,6 +26,14 @@
|
||||||
#define THREAD_PRIORITY_IDLE (-15)
|
#define THREAD_PRIORITY_IDLE (-15)
|
||||||
#define THREAD_PRIORITY_LOWEST (-2)
|
#define THREAD_PRIORITY_LOWEST (-2)
|
||||||
|
|
||||||
|
/* Process priority classes */
|
||||||
|
#define PROCESS_PRIORITY_CLASS_HIGH (4) /* FIXME */
|
||||||
|
#define PROCESS_PRIORITY_CLASS_IDLE (0) /* FIXME */
|
||||||
|
#define PROCESS_PRIORITY_CLASS_NORMAL (2) /* FIXME */
|
||||||
|
#define PROCESS_PRIORITY_CLASS_REALTIME (5) /* FIXME */
|
||||||
|
#define PROCESS_PRIORITY_CLASS_BELOW_NORMAL (1) /* FIXME */
|
||||||
|
#define PROCESS_PRIORITY_CLASS_ABOVE_NORMAL (3) /* FIXME */
|
||||||
|
|
||||||
#ifndef __USE_W32API
|
#ifndef __USE_W32API
|
||||||
|
|
||||||
/* Thread access rights */
|
/* Thread access rights */
|
||||||
|
@ -77,6 +85,8 @@
|
||||||
#define IDLE_PRIORITY_CLASS (64)
|
#define IDLE_PRIORITY_CLASS (64)
|
||||||
#define NORMAL_PRIORITY_CLASS (32)
|
#define NORMAL_PRIORITY_CLASS (32)
|
||||||
#define REALTIME_PRIORITY_CLASS (256)
|
#define REALTIME_PRIORITY_CLASS (256)
|
||||||
|
#define BELOW_NORMAL_PRIORITY_CLASS (16384)
|
||||||
|
#define ABOVE_NORMAL_PRIORITY_CLASS (32768)
|
||||||
|
|
||||||
/* ResumeThread / SuspendThread */
|
/* ResumeThread / SuspendThread */
|
||||||
#define MAXIMUM_SUSPEND_COUNT (0x7f)
|
#define MAXIMUM_SUSPEND_COUNT (0x7f)
|
||||||
|
|
|
@ -646,8 +646,8 @@ typedef struct _QUOTA_LIMITS
|
||||||
{
|
{
|
||||||
ULONG PagedPoolLimit;
|
ULONG PagedPoolLimit;
|
||||||
ULONG NonPagedPoolLimit;
|
ULONG NonPagedPoolLimit;
|
||||||
ULONG MinimumWorkingSetSize;
|
SIZE_T MinimumWorkingSetSize;
|
||||||
ULONG MaximumWorkingSetSize;
|
SIZE_T MaximumWorkingSetSize;
|
||||||
ULONG PagefileLimit;
|
ULONG PagefileLimit;
|
||||||
TIME TimeLimit;
|
TIME TimeLimit;
|
||||||
} QUOTA_LIMITS, *PQUOTA_LIMITS;
|
} QUOTA_LIMITS, *PQUOTA_LIMITS;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <napi/teb.h>
|
#include <napi/teb.h>
|
||||||
#include <napi/npipe.h>
|
#include <napi/npipe.h>
|
||||||
#include <napi/types.h>
|
#include <napi/types.h>
|
||||||
#include <ntos/minmax.h>
|
|
||||||
#include <csrss/csrss.h>
|
#include <csrss/csrss.h>
|
||||||
#include <reactos/buildno.h>
|
#include <reactos/buildno.h>
|
||||||
#include <rosrtl/thread.h>
|
#include <rosrtl/thread.h>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: proc.c,v 1.65 2004/09/13 19:10:45 gvg Exp $
|
/* $Id: proc.c,v 1.66 2004/09/19 14:36:47 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include <k32.h>
|
#include <k32.h>
|
||||||
|
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include "../include/debug.h"
|
#include "../include/debug.h"
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ GetProcessAffinityMask (HANDLE hProcess,
|
||||||
&BytesWritten);
|
&BytesWritten);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastError (Status);
|
SetLastErrorByStatus (Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ SetProcessAffinityMask (HANDLE hProcess,
|
||||||
sizeof(DWORD));
|
sizeof(DWORD));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastError (Status);
|
SetLastErrorByStatus (Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +105,7 @@ GetProcessShutdownParameters (LPDWORD lpdwLevel,
|
||||||
sizeof(CSRSS_API_REPLY));
|
sizeof(CSRSS_API_REPLY));
|
||||||
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
|
||||||
{
|
{
|
||||||
SetLastError(Status);
|
SetLastErrorByStatus (Status);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +137,7 @@ SetProcessShutdownParameters (DWORD dwLevel,
|
||||||
sizeof(CSRSS_API_REPLY));
|
sizeof(CSRSS_API_REPLY));
|
||||||
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
|
||||||
{
|
{
|
||||||
SetLastError(Status);
|
SetLastErrorByStatus (Status);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +150,8 @@ SetProcessShutdownParameters (DWORD dwLevel,
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
GetProcessWorkingSetSize (HANDLE hProcess,
|
GetProcessWorkingSetSize (HANDLE hProcess,
|
||||||
LPDWORD lpMinimumWorkingSetSize,
|
PSIZE_T lpMinimumWorkingSetSize,
|
||||||
LPDWORD lpMaximumWorkingSetSize)
|
PSIZE_T lpMaximumWorkingSetSize)
|
||||||
{
|
{
|
||||||
QUOTA_LIMITS QuotaLimits;
|
QUOTA_LIMITS QuotaLimits;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -168,25 +167,40 @@ GetProcessWorkingSetSize (HANDLE hProcess,
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
*lpMinimumWorkingSetSize = (DWORD)QuotaLimits.MinimumWorkingSetSize;
|
*lpMinimumWorkingSetSize = QuotaLimits.MinimumWorkingSetSize;
|
||||||
*lpMaximumWorkingSetSize = (DWORD)QuotaLimits.MaximumWorkingSetSize;
|
*lpMaximumWorkingSetSize = QuotaLimits.MaximumWorkingSetSize;
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
SetProcessWorkingSetSize(HANDLE hProcess,
|
SetProcessWorkingSetSize(HANDLE hProcess,
|
||||||
DWORD dwMinimumWorkingSetSize,
|
SIZE_T dwMinimumWorkingSetSize,
|
||||||
DWORD dwMaximumWorkingSetSize)
|
SIZE_T dwMaximumWorkingSetSize)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
QUOTA_LIMITS QuotaLimits;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
QuotaLimits.MinimumWorkingSetSize = dwMinimumWorkingSetSize;
|
||||||
|
QuotaLimits.MaximumWorkingSetSize = dwMaximumWorkingSetSize;
|
||||||
|
|
||||||
|
Status = NtSetInformationProcess(hProcess,
|
||||||
|
ProcessQuotaLimits,
|
||||||
|
&QuotaLimits,
|
||||||
|
sizeof(QUOTA_LIMITS));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
|
@ -720,40 +734,43 @@ FatalExit (int ExitCode)
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
GetPriorityClass (HANDLE hProcess)
|
GetPriorityClass (HANDLE hProcess)
|
||||||
{
|
{
|
||||||
HANDLE hProcessTmp;
|
|
||||||
DWORD CsrPriorityClass = 0; // This tells CSRSS we want to GET it!
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PROCESS_PRIORITY_CLASS PriorityClass;
|
||||||
|
|
||||||
Status =
|
Status = NtQueryInformationProcess(hProcess,
|
||||||
NtDuplicateObject (GetCurrentProcess(),
|
ProcessPriorityClass,
|
||||||
hProcess,
|
&PriorityClass,
|
||||||
GetCurrentProcess(),
|
sizeof(PROCESS_PRIORITY_CLASS),
|
||||||
&hProcessTmp,
|
NULL);
|
||||||
(PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION),
|
if(NT_SUCCESS(Status))
|
||||||
FALSE,
|
|
||||||
0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
|
switch(PriorityClass.PriorityClass)
|
||||||
|
{
|
||||||
|
case PROCESS_PRIORITY_CLASS_IDLE:
|
||||||
|
return IDLE_PRIORITY_CLASS;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_BELOW_NORMAL:
|
||||||
|
return BELOW_NORMAL_PRIORITY_CLASS;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_NORMAL:
|
||||||
|
return NORMAL_PRIORITY_CLASS;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_ABOVE_NORMAL:
|
||||||
|
return ABOVE_NORMAL_PRIORITY_CLASS;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_HIGH:
|
||||||
|
return HIGH_PRIORITY_CLASS;
|
||||||
|
|
||||||
|
case PROCESS_PRIORITY_CLASS_REALTIME:
|
||||||
|
return REALTIME_PRIORITY_CLASS;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NORMAL_PRIORITY_CLASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return (0); /* ERROR */
|
return FALSE;
|
||||||
}
|
|
||||||
/* Ask CSRSS to set it */
|
|
||||||
CsrSetPriorityClass (hProcessTmp, &CsrPriorityClass);
|
|
||||||
NtClose (hProcessTmp);
|
|
||||||
/* Translate CSR->W32 priorities */
|
|
||||||
switch (CsrPriorityClass)
|
|
||||||
{
|
|
||||||
case CSR_PRIORITY_CLASS_NORMAL:
|
|
||||||
return (NORMAL_PRIORITY_CLASS); /* 32 */
|
|
||||||
case CSR_PRIORITY_CLASS_IDLE:
|
|
||||||
return (IDLE_PRIORITY_CLASS); /* 64 */
|
|
||||||
case CSR_PRIORITY_CLASS_HIGH:
|
|
||||||
return (HIGH_PRIORITY_CLASS); /* 128 */
|
|
||||||
case CSR_PRIORITY_CLASS_REALTIME:
|
|
||||||
return (REALTIME_PRIORITY_CLASS); /* 256 */
|
|
||||||
}
|
|
||||||
SetLastError (ERROR_ACCESS_DENIED);
|
|
||||||
return (0); /* ERROR */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -764,50 +781,54 @@ BOOL STDCALL
|
||||||
SetPriorityClass (HANDLE hProcess,
|
SetPriorityClass (HANDLE hProcess,
|
||||||
DWORD dwPriorityClass)
|
DWORD dwPriorityClass)
|
||||||
{
|
{
|
||||||
HANDLE hProcessTmp;
|
|
||||||
DWORD CsrPriorityClass;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PROCESS_PRIORITY_CLASS PriorityClass;
|
||||||
|
|
||||||
switch(dwPriorityClass)
|
switch(dwPriorityClass)
|
||||||
{
|
{
|
||||||
case NORMAL_PRIORITY_CLASS: /* 32 */
|
case IDLE_PRIORITY_CLASS:
|
||||||
CsrPriorityClass = CSR_PRIORITY_CLASS_NORMAL;
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
|
||||||
break;
|
break;
|
||||||
case IDLE_PRIORITY_CLASS: /* 64 */
|
|
||||||
CsrPriorityClass = CSR_PRIORITY_CLASS_IDLE;
|
case BELOW_NORMAL_PRIORITY_CLASS:
|
||||||
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
|
||||||
break;
|
break;
|
||||||
case HIGH_PRIORITY_CLASS: /* 128 */
|
|
||||||
CsrPriorityClass = CSR_PRIORITY_CLASS_HIGH;
|
case NORMAL_PRIORITY_CLASS:
|
||||||
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
||||||
break;
|
break;
|
||||||
case REALTIME_PRIORITY_CLASS: /* 256 */
|
|
||||||
CsrPriorityClass = CSR_PRIORITY_CLASS_REALTIME;
|
case ABOVE_NORMAL_PRIORITY_CLASS:
|
||||||
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HIGH_PRIORITY_CLASS:
|
||||||
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REALTIME_PRIORITY_CLASS:
|
||||||
|
PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
Status =
|
|
||||||
NtDuplicateObject (GetCurrentProcess(),
|
PriorityClass.Foreground = FALSE;
|
||||||
hProcess,
|
|
||||||
GetCurrentProcess(),
|
Status = NtSetInformationProcess(hProcess,
|
||||||
&hProcessTmp,
|
ProcessPriorityClass,
|
||||||
(PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION),
|
&PriorityClass,
|
||||||
FALSE,
|
sizeof(PROCESS_PRIORITY_CLASS));
|
||||||
0);
|
|
||||||
if(!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return (FALSE); /* ERROR */
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* Ask CSRSS to set it */
|
|
||||||
Status = CsrSetPriorityClass (hProcessTmp, &CsrPriorityClass);
|
return TRUE;
|
||||||
NtClose (hProcessTmp);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
SetLastErrorByStatus (Status);
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: thread.c,v 1.4 2003/07/11 13:50:22 royce Exp $
|
/* $Id: thread.c,v 1.5 2004/09/19 14:36:47 weiden Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -33,7 +33,7 @@ CsrSetPriorityClass(HANDLE Process,
|
||||||
PULONG PriorityClass)
|
PULONG PriorityClass)
|
||||||
{
|
{
|
||||||
/* FIXME: call csrss to get hProcess' priority */
|
/* FIXME: call csrss to get hProcess' priority */
|
||||||
*PriorityClass = CSR_PRIORITY_CLASS_NORMAL;
|
*PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
|
||||||
|
|
||||||
return (STATUS_NOT_IMPLEMENTED);
|
return (STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue