O'Reilly logo

Pro Multithreading and Memory Management for iOS and OS X by Kazuki Sakamoto, Tomohiko Furumoto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8

GCD Implementation

In this chapter, I explain how GCD is implemented in order to give you a better understanding of how it works. And then I explain one functionality of GCD called “data source,” which relates to the XNU kernel event.

Dispatch Queue

This section shows how GCD is implemented. We especially look at the GCD structure and then see how a Block is executed on the dispatch queue.

Kernel-Level Implementation

From its functionality, we can guess that GCD uses the following components.

  • A FIFO queue in the C language-level to manage the added Blocks
  • Lightweight semaphore for concurrency control by atomic functions
  • A container in the C language-level to manage threads

If that is all, it doesn’t need kernel-level implementation. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required