Lecture 18
Learning objectives
After this class, you should be able to:
- Use pthreads condition variables and read write locks to write and efficient correct threaded programs.
Reading assignment
- Section 4.8 - 4.9.
- Lecture 18 slides.
- Lecture 18 example codes.
Exercises and review questions
- Questions on current lecture's material
- Modify the
example2.c
code so that the producer can have up toMAX
items unconsumed, whereMAX
is possibly greater than 1, and such that multiple consumers can run concurrently.- (Post on discussion board) Modify the above code so that it includes some of the errors mentioned in Condition Variables. Run your code many times and report the number of times you ran your code, and the number of times you encountered an error. (Instead of actually running the code multiple times, you may wish to use a loop with a large iteration count.)
- Questions on next lecture's material
- None.