mirror of
https://github.com/reactos/reactos.git
synced 2024-06-15 09:01:42 +00:00
[TASKMGR] Clamp the values returned from PerfDataGetProcessorUsage() and PerfDataGetProcessorSystemUsage() inside these functions.
It's necessary to make this clamping there so that returned values are always used consistently in taskmgr, including in places where the values are directly fetched into other functions. This is a free adaptation from Wine commit a9742b3210c4cec67aca3c0012f3b9504a4368cf From: Gerald Pfeifer <gerald@pfeifer.com> taskmgr: Move out-of-domain checking into PerfDataGetProcessorUsage() and PerfDataGetProcessorSystemUsage().
This commit is contained in:
parent
7b53126375
commit
0b4c8bdd1c
|
@ -148,8 +148,6 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
|||
* Get the CPU usage
|
||||
*/
|
||||
CpuUsage = PerfDataGetProcessorUsage();
|
||||
if (CpuUsage <= 0) CpuUsage = 0;
|
||||
if (CpuUsage > 100) CpuUsage = 100;
|
||||
|
||||
wsprintfW(Text, L"%d%%", (int)CpuUsage);
|
||||
|
||||
|
@ -179,8 +177,6 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
|||
if (TaskManagerSettings.ShowKernelTimes)
|
||||
{
|
||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
||||
if (CpuKernelUsage <= 0) CpuKernelUsage = 0;
|
||||
if (CpuKernelUsage >= 100) CpuKernelUsage = 100;
|
||||
nBarsUsedKernel = (nBars * CpuKernelUsage) / 100;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -458,7 +458,7 @@ ULONG PerfDataGetProcessorUsage(void)
|
|||
{
|
||||
ULONG Result;
|
||||
EnterCriticalSection(&PerfDataCriticalSection);
|
||||
Result = (ULONG)dbIdleTime;
|
||||
Result = (ULONG)min(max(dbIdleTime, 0.), 100.);
|
||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
||||
return Result;
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ ULONG PerfDataGetProcessorSystemUsage(void)
|
|||
{
|
||||
ULONG Result;
|
||||
EnterCriticalSection(&PerfDataCriticalSection);
|
||||
Result = (ULONG)dbKernelTime;
|
||||
Result = (ULONG)min(max(dbKernelTime, 0.), 100.);
|
||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
||||
return Result;
|
||||
}
|
||||
|
|
|
@ -422,8 +422,7 @@ DWORD WINAPI PerformancePageRefreshThread(PVOID Parameter)
|
|||
* Get the CPU usage
|
||||
*/
|
||||
CpuUsage = PerfDataGetProcessorUsage();
|
||||
if (CpuUsage <= 0 ) CpuUsage = 0;
|
||||
if (CpuUsage > 100) CpuUsage = 100;
|
||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
||||
|
||||
if (!bInMenuLoop)
|
||||
{
|
||||
|
@ -431,12 +430,6 @@ DWORD WINAPI PerformancePageRefreshThread(PVOID Parameter)
|
|||
SendMessageW(hStatusWnd, SB_SETTEXT, 1, (LPARAM)Text);
|
||||
}
|
||||
|
||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
||||
if (CpuKernelUsage <= 0)
|
||||
CpuKernelUsage = 0;
|
||||
else if (CpuKernelUsage > 100)
|
||||
CpuKernelUsage = 100;
|
||||
|
||||
/*
|
||||
* Get the memory usage
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue