|
|
onsider several threads reading some piece of data. We protect that data with
a shared mutex. Each thread obtains a shared lock before accessing the data
and releases the lock after the access is completed. It is possible that the
data is being read by at least one thread at all times. If some thread also
aims to write into the data field then such thread needs exclusive ownership.
If the thread simply attempts a lock of the shared mutex and waits for the
exclusive ownership then the waiting time may be too long. This is a situation
of starvation: one of the threads is unable to obtain a resource that it
requires. The RWMutex provides a solution for the difficulty.
|
|
|
|