Question: Consider the classic readers - writers synchronization problem described below. Several threads wish to read and write data shared between them. Some threads only want
Consider the classic readerswriters synchronization problem described below. Several
threads wish to read and write data shared between them. Some threads only want to
read the shared data readers while others want to update the shared data as well
writers Multiple readers may concurrently access the data safely, without any
correctness issues. However, a writer must not access the data concurrently with anyone
else, either a reader or a writer. While it is possible for each reader and writer to acquire
a regular mutex and operate in perfect mutual exclusion, such a solution will be missing
out on the benefits of allowing multiple readers to read at the same time without
waiting for other readers to finish. Therefore, we wish to have special kinds of locks
called readerwriter locks that can be acquired by processesthreads in such situations.
These locks have separate lockunlock functions, depending on whether the thread
asking for a lock is a reader or writer. If one reader asks for a lock while another reader
already has it the second reader will also be granted a read lock unlike in the case of a
regular mutex thus encouraging more concurrency in the application
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
