Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started