Fixed ExGetCurrentProcessorUsage (thanks to Mike)

svn path=/trunk/; revision=11295
This commit is contained in:
Alex Ionescu 2004-10-16 18:45:03 +00:00
parent 597aeb8577
commit 10d4df0a8b

View file

@ -1,4 +1,4 @@
/* $Id: sysinfo.c,v 1.51 2004/10/12 00:56:46 ion Exp $ /* $Id: sysinfo.c,v 1.52 2004/10/16 18:45:03 ion Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -54,12 +54,15 @@ ExGetCurrentProcessorCpuUsage (
{ {
PKPCR Pcr; PKPCR Pcr;
ULONG TotalTime; ULONG TotalTime;
ULONG PercentTime; ULONG PercentTime = 0;
ULONGLONG ScaledIdle;
Pcr = KeGetCurrentKPCR(); Pcr = KeGetCurrentKPCR();
TotalTime = Pcr->PrcbData.KernelTime + Pcr->PrcbData.UserTime; /* FIXME: Needs Idle Thread to be implented properly */
PercentTime = 100 - (TotalTime / Pcr->PrcbData.CurrentThread->KernelTime * 100); ScaledIdle = Pcr->PrcbData.IdleThread->KernelTime * 100;
TotalTime = Pcr->PrcbData.KernelTime + Pcr->PrcbData.UserTime
if (TotalTime) PercentTime = 100 - (ScaledIdle / TotalTime);
CpuUsage = &PercentTime; CpuUsage = &PercentTime;
} }