4010-441 Principles of Concurrent System Design
Software Transactional Memory Vending Machine

This page is accessible at www.se.rit.edu/~se441/Assignments/STM-Vending.html.

Overview

For this activity, you will work with the group assigned by your instructor to create an STM based vending machine. If you are wise, you'd consider doing this by renaming and modifying the EnergySource program. For our simulation, one day = one second.

The Vending Machine

The vending machine holds two distinct items: Cookies and Candy. While payment would be a necessary part of any real vending machine, we'll ignore this and concentrate on the vending of items only. Customers can request either a cookie, a candy bar, or a pair (one cookie, one candy). The vending machine reports either success or failure (it fails when an item requested is not available).

Replenishing Schedule

The vending machine initially has 6 of each item. Every three days (three seconds) the vending maching company representative shows up and adds enough cookies and candy to hit the inventory of 6 each.

Customers

There are five regular customers of the vending machine:

  1. CookieMonster, who likes to have 2 cookies a day, 1 each at evenly dispersed intervals. When he gets a cookie he monster prints "Me love cookies"; when he fails to get a cookie he prints "Me hungry". In either event, he will wait the 1/2 day to make his next request.
  2. Willie Wonka likes to have 1 candy bar each day at the some point during the day. When he gets a candy he monster prints "The Candy Man Can"; when he fails to get a candy he prints "Violet - you're turning violet". In either event, he will wait the either the remainder of the current day before making his next request. Note that Willie's request pattern is random.
  3. Fat Albert likes to have a cookie and a candy bar 2 - 4 times a day are randomly spaced interval. If he gets both items simultaneously he prints "Hey, hey hey!". If he fails to get both items but is able to get one of them he prints "At least I got a X", where X is either "Cookie" or "Candy". If he fails to get either item he prints "No food for me today." In any case, Albert simply waits until his next request time and tries again.

Simulation

You are to simulate 1/2 month's activity (15 seconds), after which you should shut down the simulation gracefully. Your vending machine must manage the inventory counts using shared transactional memory for each of the items. While this is bad practice in general, you should put print statements inside the transactions clearly identifying the customer, what he is trying to do, and the state of the system. To keep things readable, mid-transaction messages should be indented 4 spaces for Cookie Monster, 8 spaces for Willie Wonka, and 12 spaces for Fat Albert.

Submission

Submit your source files in a zip file (and only a zip file) named vending.zip to the Vending Activity dropbox. Your static void main method must be in the file Main.java, and all source files must be in the default package. An annotated trace output, Trace.txt, must be included in the archive showing the output from a representative simulation run. You may but need not) include a README.txt file in the archive with information about your program, including limitations, known defects, and commentary on the output produced.

Of the 10 points available for this activity,

In all cases, points assigned represent your instructor's judgement as a professional engineer, and are not subject to negotiation.