Memo Shared Records: Readers preferred.

Th Christopher
Memo home page

Memo Prog Tech

The rules of the readers-preferred shared record are these:

A solution to this problem in Memo uses three folders and an extra status record in addition to the data record.

  1. status folder, holding the status record
  2. read folder, where the data record is placed while being read and between accesses
  3. write folder, where the data record is placed to give it to a writer.
  1. nr, number of readers waiting for the record or reading.
  2. nw, number of writers waiting or writing.

The algorithms are described in terms of their implementations of the four operations.


start reading.

get the status memo

add one to nr

replace the status memo

get a copy of the data memo from the read folder


end reading

get the status memo

subtract one from nr

if nr=0 and nw>0,

get the data memo from the read folder

put it into the write folder

replace the status memo


start writing

get the status memo

add one to the number of writers

if nr=0 and nw=1

get the data memo from the read folder

replace the status memo

otherwise

replace the status memo

get the data memo from the write folder


end writing

get the status memo

subtract one from nw

if nr>0 or nw=0

put the data memo into the read folder

otherwise

put the data memo into the write folder

replace the status memo


This page last updated 04/06/97