Q9
Consider the following variant of the readers-writers problem that was discussed in Lecture 25. As before, no two writers may be in their critical sections concurrently. Also, as before, any number of readers may be in their critical sections concurrently. However, it is now OK to have up to 2 readers concurrently in their critical sections with a writer. You may use any combination of mutex locks, condition variables, and semaphores. You will get 0 points if your solution makes a thread wait when it need not or has a deadlock. You need not worry about writers getting starved by a stream of readers or readers getting starved by writers. You may use pseudo-code similar to that used in class; you do not need to use exact data type and function names from the pthreads API. You will win/lose points based on the following components/properties of your solution:
· Choice of synchronization-related variables, how you initialize them, and a succinct comment next to each describing its purpose
· Your use of synchronization-related variables with comments describing the purpose/effect of key statements and conditions