Due: Sections April 29
Doing these practice questions will help both with midterm preparation
and Project 2. There is nothing to turn in - we'll talk about solutions
during sections this week.
You shouldn't actually try to compile or run this code. Just write it,
at the level of detail of code sketches in the slides.
These solutions are not long. The first question is a bit more specific,
trying to introduce you to the pthreads implementation, which you'll use
in Project 2. The second question doesn't ask for the more mechanical
first two parts of the first question - on the other hand, it should
take only a couple minutes to complete them, and you'll have to complete
things like them in the project, of course.
- Implement counting semaphores using pthread locks (pthread_mutex_t)
and condition variables (pthread_cond_t).
- Give a typedef representing a semaphore_t "object"
- Give a semaphore_create() method
- Give a sempahore_wait() method
- Give a semaphore_signal() method
- Implement the read-writers lock example from the slides (and text)
using pthread locks and condition variables. (Do this directly - don't
say "use my counting semaphores from the first problem, then the code
on the slide.")