CMPSC 473 - Project #1 - Interprocess Communication

Due Date: February 3, 2009. 100 points

Single person project. Do your own work!

In this project, you will learn about various forms of interprocess communication (IPC) available to application processes. You will build IPC channels UNIX pipes, Linux IPC, and via shared memory, and enable two processes (a sender and a receiver) to communicate a file via these IPC channels.

The system consists of a single program that creates two processes, a parent and a child where the child is created via the fork system call. The program causes a parent process to read a file's contents and send them all to the child process via an IPC channel. The child process writes the received contents to another file.

In this project, you will have to use a variety of Linux system calls to open/read/write files, to use pipes, to use Linux IPC, and to use Linux shared memory. You will also have to build/use a library that provides abstraction of pipes over shared memory (you will have a fair bit of guidance for this).

All versions of the program work as follows: type program-name input-file output-file at the prompt. The input files will be provided. The output file created must match the input file (diff must report no difference).

Conceptually, the tasks in the project are straightforward given the directions below, but there are a number of places that you can make mistakes. In particular, you will need to understand how to use the system concepts correctly or various errors can occur. You should use gdb to debug these problems. There are ways to "attach" the debugger to either the parent or the child.

The project will consist of the following tasks:

  1. Download the following tarball Project 1 Code to your CSE account file space. You should have one file p1-ipc.tgz. There is a Makefile. You should familiarize yourself with its format and using the make command. You can build all the programs using the command make at the prompt or build individual programs, via make cse473-p1, make cse473-ipc, and make cse473-pipe.

  2. Implement a pipe-based IPC mechanism between the parent and the child (part 1). First, create a pipe to share between the parent and child. Read up on the meaning of a pipe (man pipe and via the Internet). A pipe is a bidirectional communication mechanism, but we will only use one direction; the parent will write to the pipe, and the child will read from the pipe.

    This version is to be deployed in cse473-p1.c. You will need to implement the following functions. See the function main (provided) for the overall flow. We will use the same main for all three parts.

  3. In the second task (part 2), implement a similar mechanism (parent send's file data to child) using Linux IPC. This version will be implemented in file cse473-p1-ipc.c. You will need to learn the Linux IPC system. See Linux IPC for information. The implementation for Linux IPC consists of the following steps:

  4. In the third task (part 3), we will implement yet another IPC mechanism, this time based on Linux shared memory. This version will be implemented in file cse473-p1-shm.c. Unlike the first two tasks where we use the system primitives directly, we will build a new pipe interface that uses Linux shared memory. Therefore, you will implement an IPC library called mypipe in cse473-p1-mypipe.c that you use in cse473-p1-shm.c. The semantics of mypipe are really IPC, as there is one index to read and write (like part 2). You will need to learn the Linux shared memory. See Linux IPC for information.

    The implementation of the mypipe library consists of the following steps:

    The implementation for Linux shared memory IPC using mypipe consists of the following steps. You must use the mypipe interface defined in cse473-p1-mypipe.c.

  5. Please answer the following questions regarding the project:

    1. Given the storage hierarchy on slide 31 of the 1/13 lecture, what would be the level in the hierarchy that would provide the best IPC performance? Explain as precisely as you can why we don't use that level to implement IPC.

    2. In the project Makefile, list the specifications that are used to build the mypipe library and link it into the executable file cse473-mypipe.

    3. In the Linux IPC implementation (the second task), what happens to your receiver (child) when it asks to receive a message, but the sender (parent) has not yet sent a message? Why is this the best approach from a performance standpoint?

    4. The function time measures the overall time, user-space time, and system computing time for a process. Run time for each version of the IPC program using a file called (to be provided), and include the results. Based on the measurements, use the user and system times to explain the differences in performance among the three implementations.

  6. Your submission will consist of three things: (1) A tarball of your code, made from make tar; (2) the performance results from running htest in question 4 above; and (3) answers to the project questions.

  7. Grading:


Trent Jaeger