[m-dev.] for review - new stuff for the extras directory.

Ralph Becket rbeck at microsoft.com
Mon Feb 28 23:05:26 AEDT 2000


This is great stuff!  I've been looking forward to the arrival of
coroutining/concurrency for a while.

> extrax/concurrency/spawn.m:

At first glance it looks like spawn//1 and yield//0 are independent
of whether or not the underlying concurrency model is coroutining
or pre-emptive, but the documentation for yield//0 explicitly
states that it hands over to another *coroutine*.  If this isn't a
bug and the library does assume coroutining then this should be
mentioned in the module header documentation and the docs for spawn//1.

Also, in the header comment,

% Main author: conway
% Stability: medium.
%
% This module provides `spawn/3' which is the primative for starting the
% concurrent execution of a goal.

s/primative/primitive/

> extras/concurrency/philo.m:
> 	An implementation of the classic dining philosophers program.

This implementation only uses a single, global lock and assumes the 
philosophers grab both forks to their left and right simultaneously.
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.  Feel free to
include it as an alternative if you like (NB. I haven't compiled this
yet because I don't have a suitable version of the compiler running 
yet.)

Cheers,

Ralph


begin 600 philo.m
M)2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+24-"B4 at 0V]P>7)I9VAT
M("A#*2`R,#`P(%1H92!5;FEV97)S:71Y(&]F($UE;&)O=7)N92X-"B4 at 5&AI
M<R!F:6QE(&UA>2!O;FQY(&)E(&-O<&EE9"!U;F1E<B!T:&4@=&5R;7,@;V8@
M=&AE($=.52!,:6)R87)Y($=E;F5R86P-"B4 at 4'5B;&EC($QI8V5N<V4 at +2!S
M964@=&AE(&9I;&4 at 0T]064E.1RY,24(@:6X@=&AE($UE<F-U<GD at 9&ES=')I
M8G5T:6]N+ at T*)2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+24-"B4-
M"B4 at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P@<W!A=VXH<&AI;&]S;W!H97(H(D%R:7-T
M;W1L92(L($,L($(I*2P-"B`@("!N97<H1"DL('-I9VYA;"A$*2P@<W!A=VXH
M<&AI;&]S;W!H97(H(D1E<V-A<G1E<R(L($,L($0I*2P-"B`@("!N97<H12DL
M('-I9VYA;"A%*2P@<W!A=VXH<&AI;&]S;W!H97(H(E)U<W-E;"(L("`@($4L
M($0I*2P-"B`@("`@("`@("`@("`@("`@("`@("`@<W!A=VXH<&AI;&]S;W!H
M97(H(E-A<G1R92(L("`@($4L($$I*2P-"B`@("![(&QO;W!?9F]R979E<B!]
M+ at T*#0H-"@T*.BT@<')E9"!L;V]P7V9O<F5V97(N#0HZ+2!M;V1E(&QO;W!?
M9F]R979E<B!I<R!E<G)O;F5O=7,N#0H-"FQO;W!?9F]R979E<B`Z+2!L;V]P
M7V9O<F5V97(N#0H-"@T*#0HZ+2!P<F5D('!H:6QO<V]P:&5R*'-T<FEN9RP@
M<V5M87!H;W)E+"!S96UA<&AO<F4L(&EO7U]S=&%T92P@:6]?7W-T871E*2X-
M"CHM(&UO9&4@<&AI;&]S;W!H97(H:6XL(&EN+"!I;BP at 9&DL('5O*2!I<R!C
M8U]M=6QT:2X-"@T*<&AI;&]S;W!H97(H4"P at 3"P at 4BD@+2T^#0H@("`@:6]?
M7V9O<FUA="@B)7,@:7,@=&AI;FMI;F<N7&XB+"!;<RA0*5TI+`T*("`@('=A
M:70H3"DL#0H@("`@=V%I="A2*2P-"B`@("!I;U]?9F]R;6%T*"(E<R!I<R!E
M871I;F<N7&XB+"!;<RA0*5TI+`T*("`@('-I9VYA;"A2*2P-"B`@("!S:6=N
E86PH3"DL#0H@("`@<&AI;&]S;W!H97(H4"P at 3"P at 4BDN#0H-"@==
`
end
--------------------------------------------------------------------------
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