August 2011
Intermediate to advanced
552 pages
23h 48m
English
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.
Tweak basics.m to use Thread Local Storage to store the index, number to count to, and the sleep time.
Make nodepool.m from Chapter 7: Memory thread safe so that multiple threads can allocate stuff out of the same pool.
Read now
Unlock full access