In this project you will use your monitor to make thread safe a group of processes all contending for a single file resource. They will read the end of the file, and react to what they read by appending the next line onto the file.
The threads/processes are in our story line are called Bubbles that like to drink and make teas of various flavors. The shared file will contain a list of teas a bubbles drank and in exchange, made, one exchange per line. The last line of the file then has an available tea, and any bubble that likes that flavor can take it and drink it (and replace it by making a tea of a different flavor).
NAME bubble-tea -- the bubble tea program SYNOPSIS bubble-tea [-v] [-r _flavors_] [-n _bubbles_] [-d _drinks_] _shared_file_ DESCRIPTION bubble-tea forks n processes, called bubbles, which read and write the file given as the argument to the command. The processes will read the last line of the file, and if appropriate to that process, append a new line to the file. This continues until at least a prescribed number of lines, and then the process exits. The main process exits when all forked processes had exited. OPTIONS -v verbose -r the number of "flavors" of bubble tea -n the number of "bubbles", that is, the number of forked processes -d the number of "drinks" that will be made in total, at least. FILE FORMAT The shared file has a two line header of unspecified format, followed by lines of the format, nn : nn where nn's are integers. The first is the index of the bubble the added the line to the file, and the second the drink number. The drink numbers should be ascending by one on each line of the file. HISTORY New for csc421-201. october 2019. BUGS Does not completely model the situation of concurrency. Probably does not need wait/notifies, except to improve efficiency of the solution.
author: burton rosenberg
created: 24 oct 2019
update: 4 nov 2019