[m-dev.] for review - new stuff for the extras directory.
Ralph Becket
rbeck at microsoft.com
Tue Feb 29 00:35:42 AEDT 2000
> From: Ralph Becket [mailto:rbeck at microsoft.com]
> > extras/concurrency/philo.m:
> > An implementation of the classic dining philosophers program.
>
> I've knocked out an alternative version where each fork is associated
> with a separate lock and the philosophers use the alternating
> left-right/right-left strategy to avoid deadlock.
Oops, just spotted a buglet. That code should be fine, if somewhat
inefficient, under pre-emptive scheduling, but may just sit there
doing nothing under coroutining. The solution is to change
:- pred loop_forever.
:- mode loop_forever is erroneous.
loop_forever :- loop_forever.
into...
:- pred loop_forever(io__state, io__state).
:- mode loop_forever(di, uo) is det.
loop_forever --> yield, loop_forever.
Ralph
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list