Homework #1: A Reflective Judgement and writing Assignment

advertisement
MEMORANDUM
DATE:
…
SUBJECT:
Assignment #7, IPC – threads
FROM:
Dr. Dieter Otte, CS
TO:
CS 480
DUE:
…
Goal of this Assignment:
Understanding how to use mutually accessible main memory. Understanding the implications of this.
Continue to program with threads and sync mechanisms.
Problem:
You are supposed to create a program, which demonstrates the Bounded Buffer Problem in the
following way:
Your program will, after some initialization, have three processes.
Suppose that the main process (the “Writer” or the “Producer”) reads the contents of a text file (the
name of the file is passed as a command line argument). It puts the file’s contents piece-wise in onebyte increments into a buffer. The other two processes (the “Readers” or “Consumers”) read the
characters from that buffer and output them on the screen.
Needless to say: the writer and the readers have to be synchronized. And, the two readers writing to
the screen need to be synchronized as well.
Hints:
You need to use the IPC means of the System V IPC package, specifically Shared Memory and
Semaphores.
To be handed in:
Send in an electronic copy of the program. Use the extension “.c”. Make sure that the program is
structured well and heavily commented. Be prepared to explain the inner workings of and/or
demonstrate your program.
CS 480 Handout – Assignment #7
1 of 1
Download