CS 332: Operating Systems

Using Unix shared memory

Due Wednesday, 4/9. Please submit your source code via HSP.

Write a Linux program that creates a child process, after which the following steps take place 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

On Monday, I'll talk in class about shared memory. You can get started before then by leaving out step 2 and the "user's string" part of step 4.

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).
  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.