Re: Need some advice on multithreading
Re: Need some advice on multithreading
- Subject: Re: Need some advice on multithreading
- From: David Phillip Oster <email@hidden>
- Date: Wed, 26 Nov 2008 09:00:23 -0800
At 11:42 AM -0800 11/24/08, email@hidden wrote:
No, it's not a general consensus. It's something I discovered on my
own, and posted about it here. I haven't received any overall
confirmation that it's broken, but my simple test project was able to
reliably crash on perhaps half a dozen different hardware
configurations. (And fail to crash on quite a few more.)
If you like, you can go through the original thread here and come to
your own conclusions:
http://www.cocoabuilder.com/archive/message/cocoa/2008/10/30/221452
If you want to know more about it, please feel free to ask me.
Michael, I read that original thread. The reason you are having
problems is that you are misusing the NSOperation & NSOperationQueue
system. Your test program crashes for me, reliably, just as you say,
on a 4-Core Mac.
However, if instead of using 10 NSOperationQueues, you use a single
global NSOperationQueue, the program stops crashing and becomes
reliable.
If you want serialization, then use -[NSOperation addDependency:]
that is what addDependency: is for.
Since the whole point of NSOperationQueue is to balance the mapping
from cores to threads over the whole machine to get the best
throughput for the end-user, for the end-user's mix of processes, it
makes sense that Apple intended you to have a single NSOperationQueue
per process.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden