Readers-Writers Problem | OS Interview | Skill-Lync Resources
Medium Operating Systems Synchronization

Explain the Readers-Writers problem and its solutions.

Answer

Multiple readers can read simultaneously (read-only, no conflicts), but writers need exclusive access. First readers-writers: readers preferred (writers may starve). Second: writers preferred (readers may starve). Fair solution: arrival-order access. Implementation uses semaphores/mutexes: read_count (readers currently reading), mutex (protects read_count), rw_mutex (write access). Reader: lock mutex, increment count, if first reader lock rw_mutex, unlock mutex, read, similar for exit.

Master These Concepts with IIT Certification
IIT Certified

Master These Concepts with IIT Certification

175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.

Relevant for Roles

Software Engineer Backend Developer Database Developer