The sleeping barbers have fallen so deeply asleep that their program no longer functions! The good news is the "heavy lifting" is done in that the code is provided and follows the code trace you...

The sleeping barbers have fallen so deeply asleep that their program no longer functions! The good news is the "heavy lifting" is done in that the code is provided and follows the code trace you worked previously with binary and general semaphores. The bad news is it is not running to completion :(

Adjust the code so the 2-barber, 4-customer setup runs to completion as expectedunder any interleaving. To help, you are shown an area -- ONLY MAKE CHANGES BELOW THIS LINE -- which helps show you where we expect the fix to be happening. (And nothing should be changed above that line - duh.)



SleepingBarberBrokenInterleavingV1.cpp


If you need a Makefile, this should work (or at least worked for me on campus machines!). For anyone not familiar with Makefiles, just put this file in the same directory as the source code file and enter 'make' into the terminal while in that directory. This will compile the program and create an executable named program in the directory (if it builds correctly)Makefile


Please upload ONLY the working .cpp file (file extensions are restricted). Feel free to add comments that document your fix!




May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here