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: William Bumgarner <email@hidden>
- Date: Wed, 5 Apr 2006 08:52:51 -0700
On Apr 5, 2006, at 12:59 AM, Yorh wrote:
But the app eat 76% on a G5 CPU and 100% on G4 and about 85% on
Intel core duo....
This is very strange in my thinking because this is a standard
loop... and a lot of apps use this strategy in a secondary thread.
Where is the mistake?
No mistake -- just an introduction to thread scheduling in a modern
operating system.
Every app is really just a thread of execution within the kernel. Or
threads as any given app can have multiple threads of execution that
can share memory.
The kernel will schedule CPU time for different threads based on a
number of criteria. Given that there are dozens, if not a hundred+,
threads active, there is no way that any one CPU is going to be used
by a thread in an infinite loop all the time.
As others have said, busy-wait loops went out of style in the 90s.
Use some kind of an event based trigger -- a run loop, kqueue, select
() loop or something -- to make your thread consume zero cycles until
there is real work to be done.
b.bum
_______________________________________________
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