Udi%Wisdom%Israel.CSNet%CSNet-Relay@sri-unix.UUCP (08/16/84)
A solutions to the readers and writers problem appear in the papers "A Subset of Concurrent Prolog and its Interpreter", ICOT TR-003, and Weizmann Institute TR CS83-12, and in "Systems Programming in Concurrent Prolog", Proceedings of the ACM POPL 1984. The basic idea is to merge the requests into a monitor process, which can handle read and write messages. A scheme for such a monitor follows: monitor([write(Args)|S], Data) :- serve(write(Args), Data, NewData), monitor(S?, NewData?). monitor([read(Args)|S], Data) :- serve(read(Args), Data, _), monitor(S?, Data). monitor([] , _). serve(Request,Data,NewData) :- (... whatever you want ...). It serves a sequence of read requests in parallel, and a write request delays the following request only until the data-structure that request needs is updated, rather then till the write is completed. Writes can have priority over reads by sending them on different channels, and plugging in front of the monitor a biased merge that gives higher priority to the writers channel. -- Ehud Shapiro