The program simulates a computer with multiple processors by using a priority queue. The goal is to determine how many processors should be used to process jobs most efficiently. The jobs to be processed will be arriving into the system on a random basis using the following arrival times, with specific processing times for each job type:
| Job Type | Arrival Time | Processing Time |
|---|---|---|
| A | [4, 6] | [1, 5] |
| B | [6, 8] | [2, 10] |
| C | [8, 18] | [6, 12] |
| D | [14, 24] | [9, 17] |
This data is merged together using merge sort, ordered by arrival time (highest priority before regular priority, if there’s a tie).
The arrival time is cumulative within each job type. Multiple different job types may arrive at the same time.
After creating all data sets, merging together, and sorting by arrival time, test data should look similar to this (as an example! This does not conform to all the above values):
| Job Type | Arrival Time | Processing Time |
|---|---|---|
| A | 6 | 2 |
| B | 10 | 8 |
| A | 12 | 4 |
| A | 18 | 3 |
| B | 19 | 9 |
| A | 24 | 3 |
| D | 25 | 13 |
| A | 25 | 3 |
| A | 34 | 1 |
| C | 35 | 12 |
| B | 38 | 10 |
| A | 40 | 4 |
| A | 46 | 5 |
| B | 48 | 8 |
| A | 51 | 5 |
| C | 51 | 15 |
| B | 58 | 8 |
| A | 61 | 3 |
| A | 66 | 2 |
| B | 67 | 9 |
| A | 70 | 5 |
| A | 74 | 1 |
| C | 77 | 14 |
| B | 78 | 8 |
Upon arrival a job will be placed on the waiting priority queue. If a processor is available, a job will be pulled from the priority queue. Once a job starts executing it runs to completion unless a “Highest Priority” job interrupts the running job. The interrupted job is removed from the processor, the remaining time is calculated and the job is placed back into the front of the priority queue, to be the next job executed as soon as a processor opens up (it’s arrival time should be the time it is placed back into the priority queue). If a “Highest Priority” job has the same arrival time, then the interrupted job goes behind it in the queue.
The simulation should run for 500 time units so you can generate initial report metrics. Then, continue to run for an additional 9500 time units time units before reporting final metrics:
Each test run creates a log file of actions (sample below from 2 CPU test). Run Time and Idle Time reset to 0 when a processor toggles from run to idle or idle to run:
The metrics collected will be used to determine from a potentially infinite number of processors, how many processors should be used to process jobs most efficiently. A high number of jobs in the queue (i.e. long wait times to process) or a continually empty queue (i.e. no task ever has to wait to be processed) both reflect an ineffective processing environment. The correct answer is somewhere in between. The simulation will run multiple times, changing the number of processors each time (but always using the same original data file) in order to collect sufficient metrics to make an informed opinion.