The Readers-Writers problem poses special challenges to OS synchronization strategies. Describe the Readers-Writers problem showing typical applications in real life systems. Explain how semaphores may be used to solve this problem. What are the types of possible solutions? Describe the solution for the “Second Reader-Writer Problem” and explain how it works.
A real life example of a Readers and Writers problem is an airline reservation system consisting of a huge data base with many processes that read and write the data. Reading information from the data base will not cause a problem since no data is changed while the problem lies in writing the information to the data base as data modifies in the database due to the write.
Semaphores are used in the reader writer problem, where it ensures mutual exclusion and also handles the writing mechanism and is common to the reader and writer process code. We basically use two semaphores u.e "mutex" and "wrt". where mutex ensures mutual exclusion and wrt handles te writing mechanism.
Solution to reader-writer problem :
Solution to 2nd reader-writer problem :
The second readers-writers problem requires that, once a writer is ready, that writer performs its write as soon as possible. In other words, if a writer is waiting to access the shared data, no new readers may start reading.
Get Answers For Free
Most questions answered within 1 hours.