Apple Open-Sources Grand Central Dispatch

One of the most compelling new feature in Snow Leopard is Grand Central Dispatch, which can make it easier for developers to write software taking advantage of the multiple cores in our computers. On Sept., 10 Apple (s aapl) released the user library component of Grand Central to the open source community.

We previously discussed Grand Central Dispatch, but the essence is that the operating system’s kernel is the only entity that knows all of the processes that are running on the system, so it’s in the best position to determine how to run tasks concurrently. Developers no longer have to guess as to the most efficient number of threads to spawn, or make assumptions about the available computing resources.

While Grand Central Dispatch is a boon for Snow Leopard and OS X developers, it doesn’t help the rest of the computer world, and certainly doesn’t contain enough of an advantage to convince developers who don’t already develop for OS X to start. However by open-sourcing the Grand Central Dispatch APIs, Apple is most likely hoping that other operating systems like Linux may pick up the technology. This encourages the wider adoption of the technology, which makes it stronger for all parties. It’s a win-win scenario.

One just has to look at the success of WebKit, the underlying foundation of the Safari web browser that was adopted by Google (s goog) to drive its Chrome browser. Apple is clearly seeing the advantages of open source — and even if it didn’t mean to (Apple didn’t open-source WebKit as it originated from the open source kHTML), it’s reaping the benefits of the open source community’s constant code improvements.

Ultimately, Grand Central Dispatch consists of three components, each of which are now open for public consumption, improvement and adoption:

  1. In the user-space side is the newly open-sourced libdispatch. This contains the APIs that developers call to schedule blocks of code into queues.
  2. xnu is the kernel that runs OS X, originally developed for NEXTSTEP before Apple took NeXT and Steve Jobs back. xnu stands for “X is Not Unix” and has been open-sourced from the start because it included code from FreeBSD.
  3. llvm is a relatively new “Low Level Virtual Machine” compiler technology that is ultimately designed to replace gcc which generally compiles much Unix software. While not technically required for Grand Central Dispatch, it supports a key requirement: blocks. Blocks are an extension to the C programming language that make it trivial to define portions of code that can easy be scheduled and run concurrently.

With all three components of Grand Central Dispatch now available for the open source community, it is an even more exciting prospect. Finally we can really capitalize on our multicore computers. The next 12 months will be interesting.