Tutorial :Using grand central dispatch in Linux


Is this possible, since Apple has open sourced the code (libdispatch?) I'm bit confused as to how one can make use of this. Is this like a library with an API that any application can make use of, or an OS feature built into Mac OS X? Can application built "for" Macs and iPhone (with iOS 4) alone make use of this library?

I assume one has to run a port to make gcc also compatible with the new semantic that Apple has introduced.


Having read the Ars Technica overview, it appears there are several challenges

  • GCD makes extensive use of blocks (an Apple extension to C that approximates closures) which means your compiler needs to support blocks. The standard version of gcc has no support for blocks, so you'll either have to port Apple's changes to the Linux gcc or use clang/llvm.
  • The Mac OS X version of GCD involves some code in the kernel. Clearly, if kernel changes are required to Linux to support GCD, that is a major piece of work. However, it seems that a user space only port is possible.
  • GCD is licensed under the Apache License. Apparently, this license is not compatible with GPL v2. So you cannot use GCD in any app distributed under GPL v2. GPL v3 is OK though, so an app licensed under GPL v2 "or later" is OK.

Having said all that, the FreeBSD port has been done, so it must be possible.


It's almost a year later but I'm using it quite happily on Ubuntu Natty. Proper packages are coming in Oneiric.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »