Click here to get back home

Detecting CPU usage of a Process ...

 HomeNewsGroups | Search | About
 microsoft.public.smartphone    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Detecting CPU usage of a Process ... Vipul Pathak 03-20-2008
Posted by Vipul Pathak on March 20, 2008, 10:11 pm
Please log in for more thread options
Hello Everyone,

I am designing a Task Manager for Windows Mobile Smartphone. I am using
CreateToolhelp32Snapshot() to gether process information. I have an
additional need to including CPU usage and Battery consumption by every
process.

Does any one has an Idea of how to detect CPU Usage and Battery Usage by a
given process on the Device ?

Thanks in Advance,

*(Vipul)() ;



Posted by Paul G. Tobey [eMVP] on March 21, 2008, 11:07 am
Please log in for more thread options
There's no way to get "battery usage" for a process. That doesn't make
sense.

As for CPU, look at GetThreadTimes() and add up the times for all threads in
each process.

Paul T.

> Hello Everyone,
>
> I am designing a Task Manager for Windows Mobile Smartphone. I am using
> CreateToolhelp32Snapshot() to gether process information. I have an
> additional need to including CPU usage and Battery consumption by every
> process.
>
> Does any one has an Idea of how to detect CPU Usage and Battery Usage by a
> given process on the Device ?
>
> Thanks in Advance,
>
> *(Vipul)() ;
>
>



Posted by Vipul Pathak on March 21, 2008, 11:30 am
Please log in for more thread options
Thanks Paul ...

In order to get the CPU usage in percentage, I will be using the following
Algorithm:

T1, T2, Tn are threads of their respective processes P1, P2, Pn etc.

=========================================
Time_P1 = (GetThreadTimes(T1)+GetThreadTimes(T2)+ ..... GetThreadTimes(Tn))
;
Time_P2 = (GetThreadTimes(T1)+GetThreadTimes(T2)+ ..... GetThreadTimes(Tn))
;
.
.
.
Time_Pn = (GetThreadTimes(T1)+GetThreadTimes(T2)+ ..... GetThreadTimes(Tn))
;

Total Time Consumed (lets call this: TTC) = Time_P1 + Time_P2 + ...... +
Time_Pn ;
CPU Usage for P1 = (Time_P1 / TTC) * 100 ;
CPU Usage for P2 = (Time_P2 / TTC) * 100 ;
.
.
.
CPU Usage for Pn = (Time_Pn / TTC) * 100 ;
=========================================

If you or any one else think, that this should be corrected, please let me
know.

Thanks,

*(Vipul)() ;



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
> There's no way to get "battery usage" for a process. That doesn't make
> sense.
>
> As for CPU, look at GetThreadTimes() and add up the times for all threads
> in each process.
>
> Paul T.
>
>> Hello Everyone,
>>
>> I am designing a Task Manager for Windows Mobile Smartphone. I am using
>> CreateToolhelp32Snapshot() to gether process information. I have an
>> additional need to including CPU usage and Battery consumption by every
>> process.
>>
>> Does any one has an Idea of how to detect CPU Usage and Battery Usage by
>> a given process on the Device ?
>>
>> Thanks in Advance,
>>
>> *(Vipul)() ;
>>
>>
>
>



Similar ThreadsPosted
Handhelds usage survey November 28, 2005, 6:21 am
Data Usage of Push Mail December 1, 2007, 12:32 pm
Hand-held device usage survey November 18, 2005, 6:51 am
problem with kill process March 9, 2007, 12:16 am
How to kill/stop process for Mobile 5.0 Smartphone July 25, 2006, 5:12 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap