On Sep 15, 2009, at 6:42 AM, Stéphane Letz wrote:
After reading several things on GCD on the net, it is not yet clear if GCD is mainly a "per process" library, or is supposed to have a "global view" of all processes, so that to allocate "not too much" threads in each process, and avoid having a number of threads that finally exceed the number of available cores on the machine.
"The net" is a notoriously unreliable source of information about, well, anything, but you're more than welcome to read the source code. It's available. :) To answer your question in brief, it's both. It's a per-process thread pool with cooperation from the kernel to determine, dynamically, how many threads should be in that pool given the overall load on the system. The kernel provides the "global view" here through the pthread_workqueue interface and a compage variable which tells libdispatch when to start retiring threads (and what the new target should be) in order to deal with a resource depletion scenario. - Jordan