Daniel Eran Dilger
Random header image... Refresh for more!

Apple Open Sources Snow Leopard’s Grand Central Dispatch

Prince McLean, AppleInsider

Despite being a unique, key marketing feature of Snow Leopard, Apple has decided to open the code behind Grand Central Dispatch under the liberal Apache 2.0 license.

Apple Open Sources Snow Leopard’s Grand Central Dispatch
Snow Leopard’s new Grand Central Dispatch feature, which serves as a system-wide mechanism for managing parallel task execution across multiple processor cores for developers, involves multiple components in the operating system.

The user-space implementation of the Grand Central Dispatch services API, called libdispatch, has been delivered as its own open source project, joining with other components that are part of projects Apple has already designated as open, including the kernel components in the Darwin OS XNU kernel and the blocks runtime that is part of the LLVM project.

Apple’s code giveaway was “something of a surprise,” according to MacResearch, a website covering the use of Apple technologies in the scientific research community, because the new feature of Snow Leopard “could be seen to give Apple a competitive edge in the new world of multi-core.”

However, opening the code to the community could help pave the way for its adoption. Writing for MacResearch, Drew McCormack noted, “Until today, it would have been very unlikely that any new UNIX tools would be developed on Mac OS X using Grand Central, simply because they would only run on the Mac. With the possibility that Grand Central will become available on other UNIX systems, the likelihood that Grand Central will be incorporated into command line tools is greatly increased.”

McCormack said there was little risk to Apple of sharing its new code, saying that it was “unlikely that Grand Central would be used by any direct competitor to Apple, like Microsoft,” and noting that its adoption by other Unix and Linux systems would not “really pose a threat to Apple’s consumer-based business.”

Apple contributes to and runs a variety of open source projects, from WebKit to CUPS. Some efforts to open source its code have been wildly successful, while other have seen little enthusiasm. For example, there has been no real interest in Apple’s launchd among the greater open source community out side of Mac OS X, in large measure because it would require a massive reworking of Linux in order to put it to use.

Open source support for other Apple code that is easier for others to use has been a mixed bag. There has been some limited use of Darwin Streaming Server, Apple’s RTSP streaming project incorporated in Mac OS X Server as QuickTime Streaming Server. Webkit has been wildly successful, particularly in the mobile arena. Bonjour has been implemented for Linux, and taken in new directions.

Significant new outside interest in Grand Central Dispatch could result in a wider support base for building parallelism compatible with Apple’s other open technologies, such as OpenCL. The availability of the dispatcher on Linux and other Unix operating systems would also help generate demand for other command line utilities that tap into its power. That would help Apple leverage its technologies in markets where it has a minority position, such as in the enterprise and supercomputing.

  • http://www.adviespraktijk.info Berend Schotanus


    I love the concept of GCD. It allows different processes to act independently and interact with each other and to make a decentralized approach to what the computer is doing. This is a fundamentally different approach than the “central truth” paradigm that most of the computer industry is using. For this reason it is absolutely impossible that Microsoft would adapt GCD, there is no way it would fit into their way of thinking.

    I am amazed about Apples policy to what they do and do not open for third parties. They are absolutely secretive about the regular business chit-chat that everybody wants to know. But when it comes to the big clues about how things really work it is just openly available. And nobody seems to care…

  • http://ferozedaud.blogspot.com feroze

    Maybe I am missing something, but how is this different that the concept of pooling threads, and scheduling work to them when needed? This has been around in a lot of OS’s, eg: Windows as well as in Unix and other environments.

    [The concept of a thread pool is not new, which is why Apple refers to GCD as being an instance of one. What is unique is the implementation, and that Apple has made it accessible to its developers.

    As Apple explains, “GCD combines an easy-to-use programming model with highly-efficient system services to radically simplify the code needed to make best use of multiple processors. The technologies in GCD improve the performance, efficiency, and responsiveness of Snow Leopard out of the box, and will deliver even greater benefits as more developers adopt them.

    “The central insight of GCD is shifting the responsibility for managing threads and their execution from applications to the operating system. As a result, programmers can write less code to deal with concurrent operations in their applications, and the system can perform more efficiently on single-processor machines, large multiprocessor servers, and everything in between. Without a pervasive approach such as GCD, even the best-written application cannot deliver the best possible performance, because it doesn’t have full insight into everything else happening in the system.”

    Introducing Blocks and Grand Central Dispatch

    Also look at John Siracusa’s overview at Ars Technica:

    “Those with some multithreaded programming experience may be unimpressed with the GCD. So Apple made a thread pool. Big deal. They’ve been around forever. But the angels are in the details. Yes, the implementation of queues and threads has an elegant simplicity, and baking it into the lowest levels of the OS really helps to lower the perceived barrier to entry, but it’s the API built around blocks that makes Grand Central Dispatch so attractive to developers. Just as Time Machine was “the first backup system people will actually use,” Grand Central Dispatch is poised to finally spread the heretofore dark art of asynchronous application design to all Mac OS X developers. I can’t wait.”

    – Dan]

  • Raymond

    This makes sense if you consider than the open source community would probably try to make their own clone of GCD, which would be similar but incompatible. Better the API was widely adopted and used, than Apple being isolated in this regard.

  • Pingback: FreeBSD adds support for Snow Leopard’s Grand Central Dispatch — RoughlyDrafted Magazine()