EECE-4029 Operating Systems Fall 2016
Producer-Consumer

processes, mutex, semaphores, memory management, producer-consumer, files, deadlock, more..

Sample code and documentation

Archive:
   
prodcons.tar     All code and documentation in a tar file
   
Makefile:
   
Makefile.prodcons     Make all the code below with this
   
Code:
   
00-prod-cons.c     All 'W' objects wait for a single 'N' object - 1st use of monitor
01-prod-cons.c     Same as above except there are two monitors
02-prod-cons.c     Same as above but threads do some work and main thread goes to sleep
03-prod-cons.c     All 'W' objects complete first and then all 'N' objects can complete
04-pc-err-1.c     First attempt at solving producer-consumer w/o buffer
04-pc-err-2.c     Add yield to allow OS to schedule threads more fairly
04-pc-err-3.c     Add a mutex lock and condition variable - but deadlock is possible
04-pc-err-4.c     Shows the deadlock clearly when executed
04-prod-cons.c     Simple producer-consumer co-routine, single monitor, fixed!
05-prod-cons.c     Beginning of a stream network, two monitors
06-prod-cons.c     A more complicated stream network, five monitors
07-prod-cons.c     Same as above except each monitor has a buffer
queue_a.c     Implements the buffer in 07-prod-cons
queue_a.h     The include file for queue_a.c
08-prod-cons.c     Same as 07-prod-cons except semaphores are used
 
Documentation:
motivation     Why the interest in producer-consumer?
prodcons     Graphical illustration of producer-consumer co-routining
prodcons w/ buffer     Graphical illustration of producer-consumer co-routining with buffer
prodcons w/ buffer,semaphore     Graphical illustration of producer-consumer with buffer and semaphores
pthread     Man page for pthreads
sched_yield     Calling thread yields to another thread
pthread_yield     Same as sched_yield
sleep     Sleep for a specified number of seconds