1. Home
  2. Computing & Technology
  3. Macs

Snow Leopard Preview: Snow Leopard Technologies: Grand Central Dispatch
Snow Leopard: Doing More With More

By Tom Nelson, About.com

Snow Leopard Preview: Snow Leopard introduces Grand Central Dispatch, a technology that promises to make using all of your Mac’s available processors as easy as using a single processor. About: Macs looks at what makes up this technology and how end users will benefit from it.

Part of the Snow Leopard OS, Grand Central Dispatch is a set of APIs (Application Programming Interfaces) and programming frameworks for software developers. Grand Central Dispatch operates behind the scenes, so you won’t see a user interface or any type of program for controlling or using the Grand Central Dispatch service.

What you will see is speed, with the potential for a fundamental improvement in how processors are used and exploited by developers and the applications they create.

Grand Central Dispatch

Grand Central Dispatch promises to make it easier to write code that effectively uses all of the processors in your Intel Mac. So much easier, in fact, that even first-time developers who use the Grand Central Dispatch service should be able to write code that can use all of the processors in an Intel Mac.

The challenge of effectively using multiprocessors or multi-core processors dates back to the processor arms race that began in the mid-90s and continued until recently. Back then, processor speeds were improving dramatically, with yearly increases in speed and performance. Software developers and users got a mostly free ride out of this speed race. With each new processor generation, existing applications got faster simply because the processor’s clock speed got faster.

Sure, there were new developments along the way, such as new instructions and capabilities built into each new processor that could be used in new applications to make them run even faster. For the most part, though, applications were developed for a single processor executing instructions one after another.

Eventually processor development hit a roadblock. Manufacturers could no longer keep increasing processor speed. The tradeoff was becoming unmanageable, in the form of more power and more heat being generated by the processors, all in the quest of faster clock speeds.

The solution was to abandon speed increases and look to multiple processors to perform the work. This was nothing new. Often referred to as parallel computing, this type of technology was already in use in many research environments.

Mac users first saw dual-processor machines based on the PowerPC architecture. These machines held two separate PowerPC processors, each in its own socket on the motherboard. Later Apple would use multi-core processors, which combine two or more processors onto a single dye or wafer. This creates a single package that houses multiple processor cores. Multi-core processors don’t need a faster processor. Each core can be used independently, so each core you add creates the potential for better performance.

The question was how to use all of those cores in a way that didn’t require a theoretical background in parallel computing. Enter Grand Central Dispatch.

Historically, programming for a multi-core environment required a developer to break an application into many simple tasks, known as threads. A thread can be run on any available processor, so the more threads you can break an application into, the faster it can run, theoretically. The problems were how each thread interacts with the others, how data is locked to prevent a thread change to data another thread needs, and how a thread is affected by other applications that may be running at the same time. All of these unknowns made it difficult for developers to create a well-written threaded application that made optimum use of multiple processors. You can see this today by monitoring processor usage. For many applications, only one or two processors ever see any use; the rest sit idly by, doing nothing. I see this a lot, because I keep Apple’s Activity Monitor open, so I can watch CPU and memory utilization on my Mac.

Grand Central Dispatch takes a different approach. Because it is a service woven into the Snow Leopard OS, Grand Central Dispatch knows what is going on with the OS, what applications are running, which ones are idle, what services will be needed soon, etc. Grand Central Dispatch can automatically map the blocks of code in an application to specific processors for execution, to make maximum use of all processors.

Grand Central Dispatch Pros

  • Responsiveness: Because applications written to use Grand Central Dispatch use small code blocks, the OS can be more responsive to user input, quickly responding and switching from one code block to another. Additionally, because the applications themselves are smaller, less memory and CPU overhead are needed in their execution than for a similar application written without using Grand Central Dispatch.
  • Increased Processor Utilization: Perhaps a better way to say this is: faster performance. With Grand Central Dispatch queuing up code blocks to multiple processors as needed, the effective performance of an application and its efficiency are greatly increased.
  • Easier to Write Code: Grand Central Dispatch tends to cause developers to create cleaner and less complex code. Clean code is easier to debug, as well as to profile for optimization. It also uses fewer resources to run.

Grand Central Dispatch Cons

  • Requires a multiprocessor Mac: Almost all Intel Macs are multiprocessor, but a few early Intel Mac minis used single-core Intel processors.
  • Requires New or Rewritten Applications: Grand Central Dispatch doesn’t do its magic for free. Applications must be written to take advantage of it. This means that almost all current applications can’t reap the benefits of Grand Central Dispatch. On the bright side, Snow Leopard, and many of the included applications, will use the technology right away.
Explore Macs
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Macs
  4. Mac Operating Systems
  5. Snow Leopard Mac OS X 10.6
  6. Snow Leopard Preview: Snow Leopard Technologies: Grand Central Dispatch>

©2009 About.com, a part of The New York Times Company.

All rights reserved.