Leif Asbrink wrote:
.
// prepare to support GetSystemTimes
hKernel = LoadLibrary( _T("Kernel32.dll") );
Looks like using a dll;-)
Hi Leif,
of course Kernel32.dll *is* a DLL, but not one meant specifically for the
purpose of measuring the CPU load :-)
On my old laptop this works fine:-)
It is a Pentium 4.
On the new one the code does not give the correct result:-(
The new one has a dual core centrino and the result I get
is 50% of the load indicated by the system monitor.
Well, this is what Microsoft writes on his SDK documenation :
-----------------
The GetSystemTimes function retrieves system timing information. On a
multiprocessor system,
the values returned are the sum of the designated times across all processors.
-----------------
and when they document the GetProcessTimes API, they write :
-----------------
lpKernelTime
[out] Pointer to a FILETIME structure that receives the amount of time that the process has executed in kernel mode. The
time that each of the threads of the process has executed in kernel mode is determined, and then all of those times are
summed together to obtain this value.
lpUserTime
[out] Pointer to a FILETIME structure that receives the amount of time that the process has executed in user mode. The
time that each of the threads of the process has executed in user mode is determined, and then all of those times are
summed together to obtain this value.
-----------------
So apparently the the kernel and user mode time each thread has spent on whatever processor of the CPU should be summed
together. If in your experience this is not true, then maybe there is (another) bug in Windows. I tested Winrad on a
hyperthreading Pentium IV, which should have two execution units, but did not notice anything strange. But probably a
hyperthreading Pentium is not the same as a dual core Pentium.
Is there a way to find out how many cores there are
in the system? Then I could use the system clock times
the number of cores to get the amount of total CPU
time available.
Though I have never used it, the API
BOOL GetProcessAffinityMask
( HANDLE hProcess,
PDWORD_PTR lpProcessAffinityMask,
PDWORD_PTR lpSystemAffinityMask
);
should be what you want. The SDK doc says :
-----------------
A system affinity mask is a bit vector in which each bit represents the
processors that are configured into a system.
-----------------
So the third parameter of that API should contain that information on return
from the call;
73 Alberto I2PHD
#############################################################
This message is sent to you because you are subscribed to
the mailing list <linrad@antennspecialisten.se>.
To unsubscribe, E-mail to: <[EMAIL PROTECTED]>
To switch to the DIGEST mode, E-mail to <[EMAIL PROTECTED]>
To switch to the INDEX mode, E-mail to <[EMAIL PROTECTED]>
Send administrative queries to <[EMAIL PROTECTED]>