Dining philosophers in Erlang

Thomas Arts <>
Tue Apr 16 13:59:22 CEST 2002


Hello Jani

As you know, Erlang has no notion of channels. However, you could
model Erlang's communication to any process, by NxN channels. I don't
believe that that is a nice solution, but surely possible.

I hope I understand your question right, but as far as I can see, you 
could use either synchronous communication with time-out (like in the
gen_server) orelse change the protocol to the complement and react on
a message if you are idle, hence if you don't react, you assume that
the philosopher is busy.

Good luck with your exercise
Thomas


Jani Launonen wrote:
> 
> Hello,
> 
> I've been in Formal Methods course and there were presented message passing
> language that had communications channels that could be both read and
> written. The dining philosophers -problem could be solved by storing
> "available" information about chop stick in a channel (that is dining
> philosopher process could write "available" to the channel and if it
> weren't consumed by it's neighbour, one could read it back by itself). This
> is something impossible in Erlang - as one can write only to a another
> process - so how could one solve the problem in Erlang in most elegant way?
> I cannot think of solution that doesn't involve having a chop stick process
> that has only use for responding whether chop stick in question is
> available or not. Is it possible to not to have chop stick process (and
> have the required parallelism) in most basic Erlang possible? Could someone
> more enlightened Erlanger explain this more elegant solution, please?
> 
> Cheers,
> 
> -+-+-+-
> Jani Launonen
> Student. . . . . . . . . .University of Oulu, Dept. of EE
> Assistant Researcher . . .Genie of the Net Project
> 
> "Computing is a field which has one of the shortest collective memories
> of any engineering or scientific discipline." - Marty Fouts, comp.distributed



More information about the erlang-questions mailing list