CS 332: Operating Systems

Using Unix shared memory and signals

Due 11:59PM Monday, 4/12. Please submit your source code via the Courses system.

Your job

Write a Unix program that runs on MacOS X. The program should first create a child process, and then perform the following steps indefinitely.

  1. the parent asks the user to type a string
  2. the parent stores the string in memory shared with the child
  3. the parent sends a signal to the child
  4. the child prints a message making clear that it received the signal and the user's string
  5. the child sends a signal to the parent
  6. the parent prints a message making clear that it received the signal from the child
  7. go to step 1

You'll need to use several system calls, including (but not necessarily limited to) fork, signal, kill, and shmget.

Important constraints

Since this is a fairly large class and I have no grader this term, it will be important for me to be able to read and test your programs efficiently. Towards that end, I need you to follow some simple formal specifications closely. For this assignment, this means:

  1. Write your program in a single source file named sharedmem.c (all lower case) or sharedmem.cpp, depending on whether you use C or C++.
  2. If you need to submit a revised version of your program, call it sharedmem1.c. A revision of the revision should be called sharedmem2.c, etc.
  3. Don't submit a folder for this assignment--just sharedmem.c. If you have "readme" information to communicate to me, just put it in the comment at the top of sharedmem.c.

As a concrete thank-you for your help, adhering to this specification will be worth a point on this assignment.