🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2712

Re: Getting a thread's state and CPU utilization

#2712
From: Dennis Jones
Date: Sun, 14 Jan 2007 16:52
31 lines
2066 bytes
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message 
news:999kq2l4vmj0mq60qde1gvpcom1l4arf8a@4ax.com...
> Dennis Jones wrote:
>
>>Does anyone know if there is a way to determine the state of a currently
>>running thread?
>>  I'd like to be able to find out if a thread is executing, terminated,
>
> GetExitCodeThread()
>
> or check the signal status of the thread handle.
>
> WaitForSingleObject( hThread, 0 )

Thanks, this gives a pretty generic result, but it might be all I need.


>>Also, is it possible to get a thread's current CPU utilization?
>
> I don't think in one call, but GetThreadTimes() might be used to
> accumulate statistics over several calls.

Well, I've already got the thread times data, which doesn't really tell me 
what the thread is doing *right now*, but I will be collecting a history, 
and as you say, that might help me determine if a partcular thread is stuck 
in an infinite loop, or if there were a race condition.  Unfortunately, I 
can't detect dead-lock this way, but then dead-lock doesn't eaxctly cause 
the CPU to scream either!

- Dennis 
Technical Details
Message-ID: <45aa5fbf$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.maxwell.syr.edu!panix!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <45a9e77e$1@newsgroups.borland.com> <999kq2l4vmj0mq60qde1gvpcom1l4arf8a@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2c2b36b510895e0f
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Dennis Jones" <nospam@nospam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <45a9e77e$1@newsgroups.borland.com> <999kq2l4vmj0mq60qde1gvpcom1l4arf8a@4ax.com>
Subject: Re: Getting a thread's state and CPU utilization
Date: Sun, 14 Jan 2007 08:52:32 -0800
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
NNTP-Posting-Host: 71.245.109.58
Message-ID: <45aa5fbf$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1168793535 71.245.109.58 (14 Jan 2007 08:52:15 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.maxwell.syr.edu!panix!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail