Path: utzoo!utgpu!water!watmath!clyde!att!alberta!ubc-cs!uw-beaver!mit-eddie!killer!pollux!dalsqnt!rpp386!jfh From: jfh@rpp386.UUCP (The Beach Bum) Newsgroups: comp.unix.xenix Subject: Test SCO Xenix IPC reliability Message-ID: <5693@rpp386.UUCP> Date: 22 Aug 88 05:19:17 GMT Organization: HASA, "S" Division Lines: 90 Someone was screaming about how unrealiable IPC (such as shared memory) on SCO Xenix was. I whipped this program up originally back during the great volatile debate and only discovered it again tonigh while cleaning out my home directory. When run it prints out TICK ... ... TOCK forever as each process gets a chance to execute. The code is short enough that you should be able to understand what is going on. If you can run this without any trouble then your shared memory is working just fine. Otherwise, you have troubles ... - John. ---------------------- clip out and save as volatile.c ---------------- #include#include #include #include 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; kill (loc[2], SIGUSR1); pause (); } } child () { while (1) { while (! *loc) ; write (1, ".... TOCK\n", 10); *loc = 0; 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); } -- John F. Haugh II +--------- Cute Chocolate Quote --------- HASA, "S" Division | "USENET should not be confused with UUCP: killer!rpp386!jfh | something that matters, like CHOCOLATE" DOMAIN: jfh@rpp386.uucp | -- apologizes to Dennis O'Connor