ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > Class(2017-2018-1)ZSTU > student homework directory > 2015329600042_林瞻远 >
homework_5 Version 0
👤 Author: by 843972018qqcom 2018-01-04 14:36:01
How many type of reader and writer problems?  use semaphores to solve these problems , and explain them in detail.

There are two type of reader and writer problem.



First readers-writers problem

It is possible to protect the shared data behind a mutual exclusion mutex, in which case no two threads can access the data at the same time. However, this solution is suboptimal, because it is possible that a reader R1 might have the lock, and then another reader R2 requests access. It would be foolish for R2 to wait until R1 was done before starting its own read operation; instead, R2. This is the motivation for the first readers-writers problem, in which the constraint is added that no reader shall be kept waiting if the share is currently opened for reading.


second readers-writers problem

The first solution is suboptimal, because it is possible that a reader R1 might have the lock, a writer W be waiting for the lock, and then a reader R2 requests access. It would be unfair for R2 to jump in immediately, ahead of W; if that happened often enough, W would starve. Instead, W should start as soon as possible. This is the motivation for the second readers-writers problem, in which the constraint is added that no writer, once added to the queue, shall be kept waiting longer than absolutely necessary. This is also called writers-preference.

Please login to reply. Login

Reversion History

Loading...
No reversions found.