🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.transputer
4 messages
4 total messages Started by ka Khalid Akram student-davidunt... Fri, 18 Dec 1992 20:09
Discriminated protocols
#1754
Author: ka Khalid Akram student-davidunt...
Date: Fri, 18 Dec 1992 20:09
40 lines
1389 bytes
Hi,

how does one implement discriminated protocols using INMOS ANSI C?

Eg in Occam:

	PROTOCOL NUMBER IS
	  CASE
	    whole; INT64
	    floating; REAL64
	    complex; REAL64; REAL64
	:

then when inputing:

	c ? CASE
	  whole; n
	    ...
	  floating; r
	    ...
	  complex; r; theta
	    ...

I need to use two varying length messages; one of 39 integers and one of
simply two integers.

Can this be done somehow using INMOS ANSI C?

Any help would be much appreciated.

Khalid

*===============================================================*
# Khalid Akram (Lahori)		 #
# ka@uk.ac.rl.inf		 #  still thinking ....
# University of West England	 #
# Rutherford Appleton Laboratory #
# 0235-445867			 #
*===============================================================*
Re: Discriminated protocols
#1755
Author: Rob Kurver
Date: Mon, 21 Dec 1992 19:42
21 lines
1361 bytes
In <1992Dec21.132719.23839@hubcap.clemson.edu> ka@wan.inf.rl.ac.uk( (Khalid Akram \(student-david;until 31/12/92\)) writes:

>how does one implement discriminated protocols using INMOS ANSI C?

In C (ANY transputer C), you can simply use a union and send that with
a single channel input/output pair (be they function calls or language
constructs or whatever).  Unless one member of the union is very much
larger than the other, and not sent very often, the overhead of sending
a larger message is usually compensated by the single input/output.

If you find you're transferring too much data this way, you can explicitly
input/output the union tag first, followed by the right body for the
tag.

Rob

--
     PACT                   Rob Kurver
    Foulkeslaan 87         rob@pact.nl
   2625 RB Delft     ph: +31 15 616864 
  The Netherlands   fax: +31 15 610032
Re: Discriminated protocols
#1759
Author: Jeff Urlwin
Date: Tue, 22 Dec 1992 19:44
41 lines
1756 bytes
In article <rlogin.724966959@dutncp8> rob@pact.nl (Rob Kurver) writes:
>In <1992Dec21.132719.23839@hubcap.clemson.edu> ka@wan.inf.rl.ac.uk( (Khalid Akram \(student-david;until 31/12/92\)) writes:
>
>>how does one implement discriminated protocols using INMOS ANSI C?
>
>In C (ANY transputer C), you can simply use a union and send that with
>a single channel input/output pair (be they function calls or language
>constructs or whatever).  Unless one member of the union is very much
>larger than the other, and not sent very often, the overhead of sending
>a larger message is usually compensated by the single input/output.
>
>If you find you're transferring too much data this way, you can explicitly
>input/output the union tag first, followed by the right body for the
>tag.

Yes, if all your sizes are even close:

struct _foo {
	char foo_tag;		/* union tag */
	union {			/* I forget if INMOS C has unnamed unions */
		struct foo1 foo1;
		struct foo2 foo2;
		etc...
	};
};

Jeff

>
>Rob
>
>--
>     PACT                   Rob Kurver
>    Foulkeslaan 87         rob@pact.nl
>   2625 RB Delft     ph: +31 15 616864 
>  The Netherlands   fax: +31 15 610032


-- 
--------------------------------------
jurlwin@gandalf.umcs.maine.edu
Re: Discriminated protocols
#1761
Author: Rob Kurver
Date: Wed, 23 Dec 1992 08:46
15 lines
1151 bytes
In <1992Dec22.194412.10650@gandalf.UMCS.Maine.EDU> jurlwin@gandalf.UMCS.Maine.EDU (Jeff Urlwin) writes:

>	union {			/* I forget if INMOS C has unnamed unions */

Note that ANSI C does not support or allow unnamed unions, so a compiler that
accepts them is not ANSI conforming.  I'm not sure about Inmos C, but I do
know that PACT Parallel C does not have unnamed unions.

Rob

--
     PACT                   Rob Kurver
    Foulkeslaan 87         rob@pact.nl
   2625 RB Delft     ph: +31 15 616864 
  The Netherlands   fax: +31 15 610032
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads