Test SCO Xenix IPC reliability
id for use with uunet/usenet
jbayer at ispi.UUCP
Fri Aug 26 00:42:40 AEST 1988
In article <22012 at neabbs.UUCP>, richard at neabbs.UUCP (RICHARD RONTELTAP) writes:
> [ Tested the ticktock.c program ]
>
> Welllll, I ran the test program on XENIX /386 2.2.1 and 2.2.3 with the
> same results.
>
> When the program is started the first time only one TICK/TOCK is
> printed. When it is started the second time. TICK/TOCK is infinitely
> printed.
>
> I think what happens is:
> When the shared memory is created, and the parent process has printed
> TICK, the context is switched to the child process right after the
> 'signal' command and just before the 'pause' command. When the child
> now signals the parent, the signal is caught and the parent goes the
> the next command: pause(), and waits for ever!
>
> The second time scheduling is different because the shared memory
> doesn't have to be created.
>
>
I think Richard is right. I added two sleep(1) to the program, one in
the child() and one in the parent(). With these additions the program
starts up and prints TICK/TOCK even when creating the shared memory
segment for the first time. I enclosed the new program below:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <signal.h>
int zero = 0;
int *loc = &zero;
int key = ('v' << 8) | 'o';
catch (sig)
int sig;
{
signal (sig, catch);
}
parent ()
{
while (1) {
while (*loc)
;
write (1, "TICK ....\n", 10);
*loc = 1;
sleep(1); /* added by JB 8/25/88 */
kill (loc[2], SIGUSR1);
pause ();
}
}
child ()
{
while (1) {
while (! *loc)
;
write (1, ".... TOCK\n", 10);
*loc = 0;
sleep(1); /* added by JB 8/25/88 */
kill (loc[1], SIGUSR1);
pause ();
}
}
main ()
{
int id;
if ((id = shmget (key, 3 * sizeof (int), IPC_CREAT|0666)) == -1) {
perror ("shmget");
exit (1);
}
if ((loc = (int *) shmat (id, (char *) 0, 0)) == (int *) 0) {
perror ("shmat");
exit (1);
}
loc[0] = 0;
switch (fork ()) {
default:
loc[1] = getpid ();
signal (SIGUSR1, catch);
parent ();
case 0:
loc[2] = getpid ();
signal (SIGUSR1, catch);
child ();
case -1:
perror ("fork");
exit (1);
}
exit (1);
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
It does work fine now on 386 and 286 Xenix.
Jonathan Bayer
More information about the Comp.unix.xenix
mailing list