Re: infinite loop in another thread destroy g4 CPU
Re: infinite loop in another thread destroy g4 CPU
- Subject: Re: infinite loop in another thread destroy g4 CPU
- From: Christian Stieber <email@hidden>
- Date: Wed, 05 Apr 2006 10:49:52 +0200
At 09:59 05.04.2006 +0200, Yorh wrote:
-(void)checkKeepAlive:(id)owner{
for (; ; ){
// code
}
}
But the app eat 76% on a G5 CPU and 100% on G4 and about 85% on Intel
core duo....
The loop isn't the problem, what you do inside the loop is.
If you aren't blocking there (to wait for a lock or other
input), then it will grab all CPU it can get. You need to
establish a protocol between the child thread and the
main thread to inform the child that there is something
to do (and possibly inform the main thread that the child
has completed a job), and the child should be blocking
if it doesn't have any work to do.
"Polling" for data has been a no-no for the last few decades
already, and it's not going to change.
Btw, WHERE in the world do you place the __attribute__((noreturn))
that gcc keeps complaining about? I never found out how to
place attributes on obj-c methods... which isn't a major
problem for now since all my threads understand some form
of "Quit" command, but still...
Christian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden