From Michael Collins:
"I wrote some code this morning to illustrate this usage of shared memory.
I've
attached the source code for *nix os's if you're interested. There are two
programs: bugsbunny and daffy. They each attempt to set the string in shared
memory to "Rabbit season" or "Duck season". Of course, bugs gets the first
and last word, so run him first in his own terminal window. Bugs sets the
shared memory string to "Duck season" and waits for Daffy to change it. While
bugs is waiting, we execute Daffy (pun intended) in another terminal window.
Daffy changes the string in shared memory to "Rabbit season" and exits. When,
Bugs sees that Daffy has changed the string, he changes it back to Duck
season and exits himself. "
bugsbunny.c
daffy.c
Makefile