Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #18559

Re: What is the right way to do this simple thing

Newsgroups comp.lang.c
Subject Re: What is the right way to do this simple thing
References <4f5ba2ed.1944110152@text.giganews.com> <4f5d0492.2034648234@text.giganews.com>
From Anders Wegge Keller <wegge@wegge.dk>
Date 2012-03-12 00:05 +0100
Message-ID <87d38i3fid.fsf@huddi.jernurt.dk> (permalink)
Organization SunSITE.dk - Supporting Open source

Show all headers | View raw


cri@tiac.net (Richard Harter) writes:

> On Sat, 10 Mar 2012 19:26:15 GMT, cri@tiac.net (Richard Harter) wrote:
> 
> I'm going to try this again with some background material.  Maybe that
> will help.
> 
> Imagine a network of mini-processes similar to Erlang's "processes".
> There are several possible levels of networking.  Thus all of the
> mini-processes may run within an OS thread.  They may run within
> several OS threads on a single machine.  They may run on a network of
> similar machines.  They may run on a network of different machines.
> In addition to all of the mini-processes there is process-manager that
> takes care of communication, storage allocation, scheduling, and other
> necessary functions.

 I happen to maintain a codebase that's almost as you describe. Most
of the processes run as their own OS process, the architecture is
identical enough (X86 all the way) that we don't have to worry too
much about alignment and ordering. So this real-world example have
some limitations as a general solution.

 ...

> There may be a gotcha in there that I haven't spotted.  There may be a
> fundamentally cleaner way to do it.  If so, I'd love to hear about it.

 All of the messages passed between the tasks have an identical header:

typedef struct head {
    word                length ;        /* Length of message            */
    word                dcode ;         /* Destination code             */
    word                acode ;         /* Answer destination code      */
    byte                rcode ;         /* Request code                 */
    byte                ccode ;         /* Completion code              */
} Head_t ;

 Each individual message starts off with the header:

typedef struct  turnoff_mes
{
    Head_t              head ;
    word                node ;
    word                c_type ;
} Turnoff_mes ;

 A process that receives a messag start by looking at the rcode value
in head. Each (rcode,dcode)-tuple identifies a unique message
structure, so the receiving process can cast the received message to
the appropriate struct, and process it.

 Sending a message to a specific process is as simple as including the
header with the message definitions, just like calling a function in
another translation unit, requires including the appropriate prototype
header.

 I find this pretty simple, but I've been working with this for more
than a decade, so for all I know, I could suffer from Helsinki syndrome. 

-- 
/Wegge

Leder efter redundant peering af dk.*,linux.debian.*

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-10 19:26 +0000
  Re: What is the right way to do this simple thing Don Y <this@isnotme.com> - 2012-03-10 12:57 -0700
  Re: What is the right way to do this simple thing ImpalerCore <jadill33@gmail.com> - 2012-03-10 14:12 -0800
    Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-10 23:31 +0000
      Re: What is the right way to do this simple thing Ian Collins <ian-news@hotmail.com> - 2012-03-11 13:06 +1300
        Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 00:44 +0000
          Re: What is the right way to do this simple thing Ian Collins <ian-news@hotmail.com> - 2012-03-11 14:15 +1300
            Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 04:46 +0000
              Re: What is the right way to do this simple thing Ian Collins <ian-news@hotmail.com> - 2012-03-11 21:27 +1300
                Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 17:23 +0000
                Re: What is the right way to do this simple thing Ian Collins <ian-news@hotmail.com> - 2012-03-12 10:01 +1300
                Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-13 21:18 +0000
                Re: What is the right way to do this simple thing Ian Collins <ian-news@hotmail.com> - 2012-03-14 10:23 +1300
              Re: What is the right way to do this simple thing Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-03-11 11:59 +0000
                Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 16:51 +0000
                Re: What is the right way to do this simple thing Gene <gene.ressler@gmail.com> - 2012-03-13 07:32 -0700
                Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-13 21:46 +0000
      Re: What is the right way to do this simple thing ImpalerCore <jadill33@gmail.com> - 2012-03-12 07:28 -0700
        Re: What is the right way to do this simple thing ImpalerCore <jadill33@gmail.com> - 2012-03-12 08:13 -0700
        Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-13 21:51 +0000
  Re: What is the right way to do this simple thing Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-10 14:21 -0800
    Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 01:40 +0000
      Re: What is the right way to do this simple thing Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-11 14:11 -0700
        Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-13 21:56 +0000
          Re: What is the right way to do this simple thing Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-14 14:55 -0700
            Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-15 21:55 +0000
              Re: What is the right way to do this simple thing Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-19 13:33 -0700
  Re: What is the right way to do this simple thing Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-03-10 15:21 -0800
    Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 00:47 +0000
  Re: What is the right way to do this simple thing Philip Lantz <prl@canterey.us> - 2012-03-11 01:07 -0800
    Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 16:14 +0000
  Re: What is the right way to do this simple thing Markus Wichmann <nullplan@gmx.net> - 2012-03-11 13:47 +0100
    Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 16:24 +0000
  Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 21:01 +0000
    Re: What is the right way to do this simple thing Anders Wegge Keller <wegge@wegge.dk> - 2012-03-12 00:05 +0100
      Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-13 21:57 +0000
    Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-11 23:06 +0000
      Re: What is the right way to do this simple thing Geoff <geoff@invalid.invalid> - 2012-03-11 17:34 -0700
        Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-13 22:00 +0000
          Re: What is the right way to do this simple thing Geoff <geoff@invalid.invalid> - 2012-03-13 18:12 -0700
            Re: What is the right way to do this simple thing cri@tiac.net (Richard Harter) - 2012-03-14 03:38 +0000
              Re: What is the right way to do this simple thing Geoff <geoff@invalid.invalid> - 2012-03-14 00:49 -0700

csiph-web