(Latest Revision: 11/03/2012)
CS 3750 Second Concurrent Programming Assignment
Protocol Execution
Work on this assignment in a team of two or three persons.
Step 1
Read the file
conc.cpp.
It shows how you can spawn threads and use semaphores to synchronize their
activities. The file also illustrates the use of a random number generator,
and the use of calls to sched_yield() to delay and change up the
timing of threads -- a way to stress test the code.
Optional Reading
If you wish, after looking at
conc.cpp,
you could examine
sem.h
and
sem.cpp,
which implement counting semaphores that behave precisely according to the
specifications for counting semaphores in your text book.
If you want more information about pthreads, look at the directions in
pthread_info.html
There is also some information about pthreads in our text book, and you can
consult
this repository of information about a multitude of multithreading
libraries.
Step 2.
By inserting declarations and code into
this header file template, and
this program file template,
create a solution to the concurrent programming
problem described in the problem
description.
For synchronization of concurrent threads, use only the counting
semaphores implemented by
sem.h
and
sem.cpp.
In particular, you must not add spinlocks or busy-waiting of any
kind.
The one exception is that, just as
conc.cpp.
does, you are allowed to use the pthread_mutex_t called
stdoutLock to lock stdout for printing messages.
The program template already contains all
the code needed to perform the screen output required by the finished program,
but you may want to add more output statements for diagnostic information
while you are developing the code.
When I say that the semaphores must be used to do all the "synchronization" of
concurrent threads, I mean any critical section problem or any protocol that
controls the chronological order in which threads interleave their actions.
If that's not sufficiently clear, ask me about it, because your grade will
count heavily on this issue.
Step 3.
E-mail me one
shell archive file
(only one) containing the following items:
- Your version of the protocol.h file - complete with your additions.
- Your version of the protocol.cpp file - complete with your additions.
- One or more script(s) documenting thoughtful, adequate, intelligent
testing
Send the shar file as inline text. Send no attachments. Send the e-mail
before midnight on the due date.
My e-mail address is:
john@ishi.csustan.edu
I will compile and run the program as a part of the grading procedure.
DUE DATE:
For the program due date, see
the class schedule.