O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

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

Exercises

  1. Use conditions to implement the producer-consumer problem. One thread should generate integers in the Fibonacci sequence; another should print those numbers. Use sleep() and ifdefs to vary the rate at which the two threads work, so that, depending on defined constants, either the producer or consumer ends up having to wait for the other thread.

  2. Tweak basics.m to use Thread Local Storage to store the index, number to count to, and the sleep time.

  3. Make nodepool.m from Chapter 7: Memory thread safe so that multiple threads can allocate stuff out of the same pool.

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