Bubble Tea Project

by: burt rosenberg
at: university of miami
date: 24 oct 2019
So one thread says to another thread:
   How is it going?
And the other thread says:
   It's going ok — it's a process.

Goals

The goals of this project are:

The Overview

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).

The Bubble Tea Rules

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.

Specific steps

The specific steps for this project are:
  1. Copy the [repo]/class/proj4 into your proj4 directory.
  2. Add your name to the bubble-tea.c comments, and make an initial commit.
  3. Run the program and observe that the bubble tea rules are not followed consistently.
  4. Insert enter and leave monitor calls to make the program thread safe.
  5. Consider how wait/notify/notify-all monitor calls and make the program run more efficiently.
  6. The resulting verbose output and shared file should generally match the reference.
  7. Submit for a grade.
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

author: burton rosenberg
created: 24 oct 2019
update: 4 nov 2019