home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.transputer
- Path: sparky!uunet!noc.near.net!mars.caps.maine.edu!gandalf!jurlwin
- From: jurlwin@gandalf.UMCS.Maine.EDU (Jeff Urlwin)
- Subject: Re: Discriminated protocols
- Message-ID: <1992Dec22.194412.10650@gandalf.UMCS.Maine.EDU>
- Keywords: Occam, ANSI C
- Organization: University of Maine, Department of Computer Science
- References: <1992Dec21.132719.23839@hubcap.clemson.edu> <rlogin.724966959@dutncp8>
- Date: Tue, 22 Dec 1992 19:44:12 GMT
- Lines: 42
-
- 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
-
-