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

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Feb 29 20:22:00 AEDT 2000


On 28-Feb-2000, Thomas Conway <conway at cs.mu.OZ.AU> wrote:
> Hi
> 
> Here's the simple concurrency stuff for the extras. It doesn't discuss the
> semantics at all - zs and I need to rework the paper for that. When we've
> done so, we'll include a link.
> 
> -- 
>  Thomas Conway )O+     Every sword has two edges.
>      Mercurian            <conway at cs.mu.oz.au>
> 
> Add a new directory of concurrency stuff to the extras.
> 
> extras/concurrency/README:
> 	A short readme file describing the contents of the directory.
...
> This directory contains stuff for doing coroutining with deterministic goals.
> See the two example programs:
> 	philo	- the dining philosophers example
> 	midimon	- a midi data monitor that concurrently reads the bytestream,
> 		  parses the midi messages, and writes out the results.
> 

I suggest you write `midi' as  `MIDI', since it is an acronym, and I suggest
that you also spell out the acronym, e.g. `MIDI (Musical Instrument Digital
Interface)'.

> :- pred byte0a(hex, hex, status, stream(byte), stream(message),
> 		io__state, io__state).
> :- mode byte0a(in, in, in, in, in, di, uo) is det.
> 
> byte0a(x0, LSN, Status, Ins, Outs) -->
> 		{ hex2byte(x0, LSN, Byte) },
> 		byte1b(Status, Byte, Ins, Outs).

Some comments around here would help.

> :- pred help(io__state, io__state).
> :- mode help(di, uo) is det.
> 
> help -->
> 	write_strings([
> "usage: midimon [-h] [--input-file|-i <filename>]\n",
> "	-h			print this help message.\n",
> "	--input-file|-i <file>	read from <file> (default is /dev/midi).\n"
> 	]).

"[-h]" should be "[-h|--help]".

> %---------------------------------------------------------------------------%
> % Copyright (C) 2000 The University of Melbourne.
> % This file may only be copied under the terms of the GNU Library General
> % Public License - see the file COPYING.LIB in the Mercury distribution.
> %---------------------------------------------------------------------------%
> %
> % Main author: conway
> %
> % The classic "Dining Philosophers" problem, to show how 

That comment is incomplete.

> :- pragma no_inline(spawn/3).
> :- pragma c_code(spawn(Goal::(pred(di, uo) is cc_multi), IO0::di, IO::uo),
> 		will_not_call_mercury, "{
> 	MR_Context	*ctxt;
> 	ctxt = create_context();
> 	ctxt->resume = &&spawn_call_back_to_mercury_cc_multi;
> 		/* Store the closure on the top of the new context's stack. */
> 	*(ctxt->context_sp) = Goal;
> 	ctxt->next = NULL;
> 	schedule(ctxt);
> 	if (0) {
> spawn_call_back_to_mercury_cc_multi:
> 		save_registers();
> 			/* Get the closure from the top of the stack */
> 		call_back_to_mercury_cc_multi(*((Word *)MR_sp));
> 		destroy_context(MR_ENGINE(this_context));
> 		runnext();
> 	}
> 	IO = IO0;
> }").

The references to MR_sp should all be inside
`#ifndef MR_HIGHLEVEL_CODE' (or maybe it is MR_HIGH_LEVEL_CODE,
I forget).  The #else case can just call fatal_error() for now.

Apart from that, this looks good.  Thanks.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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