Signal problem

root at datagen.UUCP root at datagen.UUCP
Fri Oct 14 07:57:48 AEST 1983


A friend of mine recently called because of a problem she was having
with pipes and signals.  When she explained what she wanted to do
her solution seemed to be reasonable.  Unfortunately, the program did
not work on either the machine that she was targeting the program for
(a PDP-11 running V7) or a VAX 11/780 running 4.1BSD.

The problem was to have a single process send data to one of several
child processes via a pipe.  A single file descriptor was used for
the pipe between the 'writer' and all of the children, the 'readers'.
Each of the children did a pause (2) waiting for a signal.  The writer
would take the data, write it onto the pipe and send a signal to one
(and only one) of the children, which then woke up, read and processed
the data, signaled the writer (who had paused in the meanwhile) and
finally re-paused waiting for the next time it had work to do.

The problem experienced was that the writer would apparently loose
the signal the child sent which indicated it had processed the data.
Note that this was not a rare occurance, the problem occured frequently
and relatively soon after the writer was started, but not necessarily
immediately nor after the same number of iterations.

Several notes:
1) The problem did occur on two different machines running
different versions of the kernal.

2) It did not help when the 'pause' was
replaced by a routine which slept and waited for a flag to be set by
a signal catching routine (I was willing to try anything once!).

3) The problem did NOT occur when I tried the program on my System III
development system, nor do I see anything obviously wrong with the program.

A simple (and I do mean simple!) version of the pseudo-code for these
processes is below.

Does anyone have any ideas what the problem is?

Joe Boykin
Data General Corp.   (Distributed Systems Group)
...(decvax!ittvax, allegra, rocky2)!datagen!boykin

---------------------------------------------------------------------

Writer:
	for(;;) {
		read data
		write data onto pipe
		kill(appropriate child, SIGTERM);
		pause();
	}

reader (one of many):
	for(;;) {
		pause();
		read data from pipe
		kill(writer, SIGTERM);
	}



More information about the Comp.unix.wizards mailing list