I'm writing some monitoring routines for Windows CE in order test other
applications I'm writting.
I have found some methods to retreive: Memory and system information
however, nothing to measure CPU load. I know some software exist (e.g.
RhinoStats) but what I need is a C++ code as I plan to use it whithin my
apps.
If anyone can help me, I would be very graithful.
Thank's in advance
Oscar
--
Andrey Yatsyk [Windows Embedded MVP]
"Oscar" <os...@oscarland.com> wrote in message
news:O0c$Jf8mEH...@TK2MSFTNGP11.phx.gbl...
Now, I'm able to calculate times for whole threads in the system.
I'm calculating the differences between two samples of :
TotalKernelTime, TotalUserTime, TotalCreationTime, TotalExitTime.
Know, how can I use these values to measure the CPU load ?
Thank you again
"Oscar" <os...@oscarland.com> wrote in message
news:OFJEAt9m...@TK2MSFTNGP10.phx.gbl...
Calling Thread32Next returns a struct THREADENTRY32, of which the member
"th32ThreadID" is given as DWORD. However, I need a HANDLE to that
thead in order to call GetThreadTimes(..).
I tried to cast "th32ThreadID" to HANDLE, but it does not work. I got
Error 6: ERROR_INVALID_HANDLE.
So the question is: how can I retrieve the HANDLE of a thread frim its
ID. ? (With evc++ 3.0 of course).
Thanks
Oscar
many thanks
Oscar
int SumThreadTimes()
{
HANDLE hThreads = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
int newKernel =0;
int newUser =0;
if(hThreads)
{
THREADENTRY32 entry;
entry.dwSize = sizeof(THREADENTRY32);
BOOL more = Thread32First(hThreads, &entry);
if(!more) return;
FILETIME creation, exit, kernel, user;
// add up times from all threads
while(more)
{
if(GetThreadTimes( (HANDLE) entry.th32ThreadID , &creation,
&exit, &kernel, &user)==0)
{ // HERE THE CALL RETURNS INVALID_HANDLE
/***************/
break;
}
//try we LowBytes, High Bytes keep inchangeable most of the time
newKernel += kernel.dwLowDateTime;
newUser += user.dwLowDateTime;
entry.dwSize = sizeof(THREADENTRY32);
more = Thread32Next(hThreads, &entry);
}
CloseToolhelp32Snapshot(hThreads);
--
Andrey Yatsyk [Windows Embedded MVP]
"Oscar" <os...@oscarland.com> wrote in message
news:O2JuPCyn...@TK2MSFTNGP09.phx.gbl...
Oscar