Free Synchronization lessonsSynchronization · Stage 2 · The classic problems · Step 2
Readers and writers
Allow many readers or one writer, and see how a simple preference rule can starve the other side. About 12 minutes.
What can go wrong with a readers-writers lock that always lets new readers in while others are reading?
- AA waiting writer can starve if readers keep overlapping
- BReaders can corrupt the data
- CIt always deadlocks
Show the answer
A waiting writer can starve if readers keep overlapping. The reader count never drops to zero, so the writer never gets exclusive access.
4 questions on this idea
Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.
Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve