• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: infinite loop in another thread destroy g4 CPU
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >infinite loop in another thread destroy g4 CPU (From: Yorh <email@hidden>)

  • Prev by Date: +[NSPasteboard pasteboardByFilteringData:ofType:] returns nil
  • Next by Date: Mouse pointer problems
  • Previous by thread: Re: infinite loop in another thread destroy g4 CPU
  • Next by thread: NSThread close (exit)
  • Index(es):
    • Date
    • Thread