Re: interprocess messaging to/from many grandchildren

phil-news-nospam_at_ipal.net
Date: 08/05/03


Date: 5 Aug 2003 00:52:18 GMT

On Mon, 04 Aug 2003 16:54:56 -0600 Marc Rochkind <rochkind@basepath.com> wrote:

| On 4 Aug 2003 20:55:55 GMT, <phil-news-nospam@ipal.net> wrote:
|
|> I want to have a large number of child processes communicating
|> with a grandparent process. The number of children may be larger
|> than the number of file descriptors a process can have, so I do
|> need to rule out having separate pipes to each child. Further,
|> since it is the grandparent doing the communications, setting up
|> pipes in the middle process (child of the grandparent) which is
|> doing the network listen and forking each child, will be hard to
|> do, anyway. Byte stream pipes will also not be good because the
|> messages need to stay intact and not be mingled with other messages
|> coming from other children, while they may be larger than the
|> maximum a pipe can convey without that risk. And finally, the
|> grandparent needs to send messages back and be sure the correct
|> child gets it. I will not be using threads.
|>
|> What is the best way to do this? What is the 2nd best way? It
|> does not need to be super portable, but it must work on Linux and
|> should work on the BSDs and Solaris.
|>
|
| For small messages -- a couple of hundred bytes or fewer -- SysV messages
| will probably be fastest, and are very easy to set up.
|
| For large messages, shared memory + semaphores will be fastest.

The messages could be as much as 64K bytes. Sharing memory could be a
problem because of the large number of children, and stuffing that many
shared spaces into the grandparent process VM.

| However, be warned that the so-called "semaphore initialization solution"
| that Stevens describes doesn't work on FreeBSD (and possibly on other BSD
| systems) because their implementation doesn't properly set the times.

I'm really wanting to avoid semaphores of any kind. Shared memory plus
signals might work, if I can address the sharing problems effectively
(which I have doubts about).

| Also, one quasi-BSD system, Darwin, doesn't have SysV messages.

Darwin is not a big concern. It's a server application.

| Best of all is to encapsulate the actual mechanism in a wrapper so you can
| try alternatives once the application is running.

Hopefully I can do that. I'm starting to think at the moment to use UDP
bound to the localhost address. But each child will have to have its own
localhost port (the port would then by the identity of the child), and
that could be using up a lot of them. The grandparent needs to be able
to respond to the correct child, but it doesn't need to know it's PID.

I'm also going to think about some other models to do this instead of the
GP/P/C relationship I have now.

-- 
-----------------------------------------------------------------------------
| Phil Howard KA9WGN       | http://linuxhomepage.com/      http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/   http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------


Relevant Pages

  • interprocess messaging to/from many grandchildren
    ... I want to have a large number of child processes communicating ... need to rule out having separate pipes to each child. ... since it is the grandparent doing the communications, ...
    (comp.unix.programmer)
  • Re: interprocess messaging to/from many grandchildren
    ... > I want to have a large number of child processes communicating ... > need to rule out having separate pipes to each child. ... > since it is the grandparent doing the communications, ...
    (comp.unix.programmer)
  • Re: interprocess messaging to/from many grandchildren
    ... > need to rule out having separate pipes to each child. ... > since it is the grandparent doing the communications, ... Also, one quasi-BSD system, Darwin, doesn't have SysV messages. ...
    (comp.unix.programmer)
  • Re: Calling method of grandparent in CLOS
    ... But in this case I have a grandparent class that has some instance ... There is a parent class that inherits ... And now I have a new child ... inherit two other classes from it and the parent/grandparent ...
    (comp.lang.lisp)
  • Re: Grandparent troubles
    ... There are two possible scenarios here, one involving social services, ... In the case of b or c, the case will be referred to CAFCASS, who will ... best interests of the child are. ... which may involve the Grandparent as a suitable ...
    (uk.legal)