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

Thomas Conway conway at cs.mu.OZ.AU
Tue Feb 29 09:15:57 AEDT 2000


On Mon, Feb 28, 2000 at 11:05:26PM EST, Ralph Becket wrote:
> 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.

The terminology I use to make things clear is:

parallelism	- using multiple CPUs, doing things *at*the*same*time*

concurrency	- giving a model to the programmer that includes the
		  *concept* of multiple things happening at once

So what this library is providing is just concurrency. Parallelism is
possible - if you compile in the grade asm_fast.gc.par, then you can
start up multiple engines, and get both parallelism and concurrency.

If you read the comment above the declaration for spawn/3, you'll
notice that its semantics only mention the interleaving of IO
operations. This means that it is unspecified whether in operational
terms, execution is parallel or interleaved-sequential.

> 
> 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/
> 

Thanks, I'll fix that.

> > 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.)

I had half a dozen versions that used different strategies, including
some that could deadlock. I just included the one for demonstration
purposes. I'll have a look, and include yours too since it provides
another example, if it is interestingly different.

Thomas
-- 
 Thomas Conway )O+     Every sword has two edges.
     Mercurian            <conway at cs.mu.oz.au>
--------------------------------------------------------------------------
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