IPC Shared Memory and POSIX Semaphores

CS162 Systems Programming
MP8 IPC Shared Memory and POSIX Semaphores

Write two programs producer.c and consumer.c to be invoked as follows:

./producer KEYVALUE FILENAME1 &
./consumer KAYVALUE FILENAME2 &

The producer creates an IPC shared memory segment of size 4KB. It will refer to the segment using the supplied KEYVALUE. It will then create a POSIX semaphore with the same KEYVALUE. In the meantime the consumer will have access to both IPC shared segment and POSIX semaphore using the same KEYVALUE.

The producer will then open the file FILENAME1 for reading, and the consumer will create the file FILENAME2 for writing. The the producer will fill the 4KB shared segment repeatedly with data from the file, while it has the semaphore. It will then release the semaphore to allow the consumer to write the 4KB data to FILENAME2. This is repeatedly done, until the entire file FILENAME1 is copied to the shared memory segment by the producer, and written to FILENAME2 by the consumer.

For details on POSIX semaphores, a short tutorial is available in
http://www.cs.cf.ac.uk/Dave/C/node26.html

For details on IPC shared memory, a short tutorial is available in
http://www.cs.cf.ac.uk/Dave/C/node27.html

Although the sample programs in these tutorials are quite helpful, this programming laboratory exercise is asking you to do something slightly different from those sample programs.

Deadline for submission:

4:30 PM today February 8, 2010, via email attachment to prmanalastas@gmail.com. The usual file naming convention (a zipped directory with name "lastnameFirstname-mp8-sharedmem.zip") is expected as attachment.

Sign in  |  Recent Site Activity  |  Terms  |  Report Abuse  |  Print page  |  Powered by Google Sites