Solution to the Readers and Writers problem using Message Passing

In this solution to the Readers/Writers problem, Message Passing is used to prevent a writing process from writing into the database while another process is either reading or writing. The following solution assumes that readers and writers send their requests to a database server process that ensures that the above property holds.


  Reader()
  {

    while (TRUE) {
          send (server, ReadRequest);
          receive (server, value);
          display (value);
         }
  }

  Writer()
  {

    while (TRUE) {
          create_data (&value);
          send (server, WriteRequest, value);
          receive (server, WriteOk);
         }
  }

               
IPC Home   Subway    Problems   Readers/  
  Page       Map                Writers