multi-threaded, multi-process producer/consumer example?

From: ian douglas (google_at_w98.us)
Date: 07/29/04


Date: 29 Jul 2004 11:42:10 -0700

I have one process that will be multi-threaded. The parent (A) will
sit and deal with TCP/IP issues, and feed data to its child process
(B) via shared memory. I need assistance in finding a good example of
(B) pausing (not in a busy-wait loop) until it gets a signal from (A)
that data is ready.

That the child process (B) will then have a shared memory segment with
a second running process (C), where (B) will be the producer for (C),
so (B) must also be able to get a signal from (C) to pass it more data
once (C) is ready to accept more data.

(C) then is a consumer for (B), and a producer for a thread (E) of
another separate process (D). (C) should also sit in a loop (not
hogging up cpu cycles), to get signals either from (B) or (E) to do
its work.

(D) that will deal with another TCP/IP connection, and will consume
data from its child (E). This child (E) will be a consumer for (C) and
a producer for (D).

Specifically what I need to find is a clear, documented example of how
a process can sit quietly, without hogging up CPU cycles, and wait for
a signal before acting on that signal. Having an example for dealing
with a signal from a parent or child thread, and having another
example for dealing with a signal from an external process (passed by
the OS?), is what I'm looking for.

Test platform is Fedora Core 2, 2.6.6 kernel. Production platform will
likely be RedHat 8.0 running some variant of the 2.4 kernel.

Thanks for any tips or samples.

-id



Relevant Pages

  • [PATCH] utrace: remove indirections
    ... With utrace as the new singing dancing ... typedef struct utrace_get { ... * Called with the siglock held before dequeuing pending signals. ... * from seeing its child in TASK_STOPPED state when it waits with WSTOPPED. ...
    (Linux-Kernel)
  • Re: using fork and wait reliably w/signals
    ... > I don't know what the book says about signals. ... you should wait for the child. ... > the parent process will exit soon anyway, ... If the system is not POSIX compliant, then you can ignore the SIGCHLD ...
    (comp.os.linux.development.system)
  • Re: system(), popen(), and SIGCHLD
    ... >which need to be added to each command line, ... termination of the child created by systemhave all completed by the ... command executed by that shell. ... and should be affected by signals. ...
    (comp.unix.programmer)
  • Re: Executing 2 processes "fork()" alternatively
    ... I want the parent and the child to be executed alternatively. ... One of them is using signals, but they need to be used with great ... The first pipe ...
    (comp.unix.programmer)
  • Re: restarting child processes
    ... > requests(from its clients). ... handles the signals itself. ... Happily, when a child dies for an unhandled signal, ... void install_signal_handlers{ ...
    (comp.unix.programmer)