• Grand Central Dispatch: building for the future

    Much has been made of the fact that there are not a lot of new features in Snow Leopard from a user point of view. While it's true that from a marketing standpoint Snow Leopard could have made a much bigger splash, especially this close to the Windows 7 release, Apple deserves some real credit for doing the right thing from an engineering point of view. Snow Leopard fixes a lot of what was broken in Leopard, provides real speed and usability improvements, and most importantly builds in solid support for technology - such as multi-core processors - that will be central to computing in the years to come.

    I want to take a brief look at one of the most significant new "under-the-hood" elements of Snow Leopard: the Grand Central Dispatch (GCD) model. GCD provides a set of extensions to common programming languages - specifically C, C++ and Objective C - that make it easier to take advantage of the multiple cores on modern processors. Cores are essentially separate computing engines located on the same chip that allow tasks to be handled in parallel - simultaneously - rather than one at a time.

    The problem with this approach in software - called task parallelism - is that it requires a lot of challenging work for the programmer. Computing jobs need to be broken up intelligently into tasks, and these tasks need to be farmed out to separate cores. That's being handled in threads by modern code. Programmers need to ensure that each thread has the resources it needs, that it locks the data that it's using and releases it when it's done, and that no other threads are using the resources at the same time. Complicating all of this is the fact that the programmer has no way of knowing whether the code will be run on a dual-core or quad-core chip... or some future William Gibson thousand-core black-ice über-mainframe.

    GCD allows the programmer to define units of code and data into Blocks, which can then be put on Queues for scheduling. The system then handles execution of all the scheduled Queues in an efficient, coordinated way, rather than letting individual programs grab resources willy-nilly. Apple's clearly invoking Grand Central Station to suggest the efficient flow of large volumes of traffic. It's an apt metaphor: the amount of parallelizable code will likely grow enormously to take advantage of faster chips with more cores. Leaving thread management up to individual programs, as in the status quo, will likely lead to worse and worse pile-ups.

    The Windows 7 release will certainly be a big media splash. Hopefully, we'll also see real improvements in the underlying technology on which most of the world's PCs depend. It will be interesting to see which architecture best takes advantage of future processors as the technology continues to advance.
  • Connect With Us

  • Twitter Box

  • Facebook