Question: 1- The readers-writer problem is a common problem in many computer systems where there are many threads attempt to access shared data at the same

1- The readers-writer problem is a common problem in many computer systems where there are many threads attempt to access shared data at the same time. Some threads may want to read the data while other threads want to modify the data. To prevent data inconsistency, any solution i. Prevent a writer from writing while one or more readers are ii. iii. reading. Prevent a reader from reading while a writer is writing. Allow up to 3 reader threads to read the data at the same time. The following solution only satisfy i and ii: int data 0; semaphore mutex 1 Writer Reader while (1) while (1)( wait(mutex) write data signal(mutex) wait(mutex); read data signal(mutex) Using additional semaphore(s), extend the given solution so it will satisfy all three constrains
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
