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. ...

Get Pro Multithreading and Memory Management for iOS and OS X now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.