CMSC 206: Data Structures

Due on Tuesday, November 1, 2016


Simulatinfg a Printer Usage

A Computer Lab has a monochrome printer that prints 10 pages per minute. In any given hour there are 10 students working on their assignments. Each student prints something on the printer upto twice in an hour. Each print job could be anywhere from 1 to 20 pages long. That is, there are, on average, 20 print jobs in an hour. Do a simulation (as described in class) to determine, in an hour, what the average wait time for a student to wait for their print jobs to be finished. Based on the results, answer the following:

1. Is the wait time reesonable? (What is reasonable? You decide)
2. What would be the average wait time, if the printer were replaced by a new color printer. However, it prints at 5 pages per minute.

Technical Hints:

As designed in class, you will need the following two classes: Task, and Printer. Use the code priovided. The skeletal main program is also provided here. Also, the main simulation algorithm is described below:

simulate(seconds, ppm) : Perform the simulation for given time (seconds) for a printer that prints at speed (ppm)

   - Create a new printer at speed ppm
- Create a new printerQueue (a queue of Tasks)
- Create an array to record wait times

- for each tick (second)
- if there is a new task (see function newTask())
- create a new task and add it to the printerQueue

- if printer is not busy the printerQueue is not empty
- remove next task from printerQueue
- record wait time for this task
- start the next task on the printer

- printer prints for 1 second - compute average wait time & print results

What to Hand-in:

  1. A complete printout of the latest version of your program(s)
  2. a prinout of your program showing the results for simulations requested.
  3. Answer to the two questions posed above.

Back to CS206 Course Materials