FINAL EXAM SCHEDULE: Monday 5/4 3-6pm Ricketts 203 ================================================= semaphore empty = 12, full = 0; semaphore mutex = 1; int index_producer, index_consumer; /** PRODUCER **/ while ( true ) { /* produce an element */ wait( empty ); /* any empty slots? */ wait( mutex ); /* add element to empty slot of buffer */ /* what do we do if the buffer is full? */ signal( mutex ); signal( full ); /* signal there's one more element to consume */ } /** CONSUMER **/ while ( true ) { wait( full ); /* any full slots? */ wait( mutex ); /* consume item from the buffer */ signal( mutex ); signal( empty ); /* adds one to empty */ }