FOR PMY 1733 ONLY

profileMesfer almesfer
first.zip

results.csv

Job Name Starting Tick Ending Tick Duration
J2 2 2 0
J1 1 10 9
J4 4 12 8
J6 6 14 8
J10 10 14 4
J9 9 17 8
J8 8 19 11
J7 7 20 13
J5 5 25 20
J3 3 37 34

PA4.docx

Programming Assignment #4

Your organization has purchased a new parallel computer (or "cluster") which has several processors. Your task is to design and implement a simple shortest-job-first scheduler that allows multiple users to access the cluster at the same time, as per the following specification:

The scheduler performs all required functions at regular intervals, often called "ticks." During each tick, the scheduler must take into consideration several pieces of information:

1. Are there jobs in our input file that contains a list of jobs to be run? If so, add that job to our list of current jobs. Note that our jobs file contains one job per line in the following format: "<JOB_NAME> <CPUS_REQUIRED> <DURATION>". Only one job may be added to the jobs queue during any given tick. If a job has a name of "NULL," skip that job for the current tick (i.e. no jobs will be added during this tick). If a job requires more CPUs than the cluster contains, you should output an error and terminate execution of the program.

2. Are there jobs in the jobs queue? If so, find the job with the shortest duration. Are there enough CPU resources for this job to run? If so, begin execution (i.e. add to the active jobs queue). If, after adding the previous job, are there enough resources to run the next job in the queuejob? If so, go back to the beginning of step #2. Stop adding to the list of active jobs when there are not enough CPU resources available for the job to execute. Try again in the future.

3. For each executing job (note that there may be multiple concurrent jobs), perform one tick's worth of work. After, check to see if the job is done executing. If complete, remove from the active jobs queue and allocate the job's CPU resources back into the resource pool. Note that it is possible for a job with a duration of 1 to be scheduled, executed, and completed during the same tick.

Upon completion, your program should produce a CSV file called "result.csv" that documents the point at which each job enters the jobs queue, finishes its execution, and the difference between these two values.

Sample Jobs File

Below is a sample jobs file that you can use for testing:

12

J1 8 10

J2 2 1

J3 12 12

J4 10 2

J5 5 8

J6 4 2

J7 4 6

J8 2 5

J9 4 3

J10 6 2

Sample Output

Included with this document is the file "output.txt" that contains the output of my program running the sample jobs list with a CPU count of 12 (as specified in the first line of the input file). Also included is the generated CSV file.

Header Comment, and Formatting

1. Be sure to modify the file header comment at the top of your script to indicate your name, student ID, completion time, and the names of any individuals that you collaborated with on the assignment.

2. Remember to follow the basic coding style guide. A basic list of rules is included with this document.

Deliverables

You must upload your program and reflection as a ZIP file through Canvas. Remember that your submission must either contain a CodeBlocks or Visual Studio project file!

Reflection Essay

In addition to the programming tasks listed above, your submission must include an essay that reflects on your experiences with this homework. This essay must be at least 350 words long. Note that the focus of this paper should be on your reflection, not on structure (e.g. introductory paragraph, conclusion, etc.). The essay is graded on content (i.e. it shows deep though) rather than syntax (e.g. spelling) and structure. Below are some prompts that can be used to get you thinking. Feel free to use these or to make up your own.

· Describe a particular struggle that you overcame when working on this programming assignment.

· Conversely, describe an issue with your assignment that you were unable to resolve.

· Provide advice to a future student on how he or she might succeed on this assignment.

1. Describe the most fun aspect of the assignment.

1. Describe the most challenging aspect of the assignment.

1. Describe the most difficult aspect of the assignment to understand.

1. Provide any suggestions for improving the assignment in the future.

Grading

Your grade will be determined as follows:

· [10] Your program uses a priority queue to model the scheduler.

· Your program uses good Object Oriented Programming principles. As evidence of this, your program uses classes to represent:

· [5] A given job

· [5] A CPU within the cluster

· [5] The cluster of CPUs itself

· [10] Your reflection essay satisfies the requirements as specified earlier in this document.

· [5] Your code is well documented and generally easy to read.

· [60] Does the code compile and run successfully on my test cases? Does the generated CSV file appear to be correct?

output.txt

*** Tick: 1 *** Processing jobs file... The next job in the list is: J1. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 1. Adding highest priority job: J1 8 10 Jobs queue is empty. Running active jobs... *** Tick: 2 *** Processing jobs file... The next job in the list is: J2. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 1. Adding highest priority job: J2 2 1 Jobs queue is empty. Running active jobs... Job "J2" is complete. Freeing up resources. *** Tick: 3 *** Processing jobs file... The next job in the list is: J3. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 1. Not enough free CPUs (requested: 12, actual: 4). Waiting for resources... Running active jobs... *** Tick: 4 *** Processing jobs file... The next job in the list is: J4. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 2. Not enough free CPUs (requested: 10, actual: 4). Waiting for resources... Running active jobs... *** Tick: 5 *** Processing jobs file... The next job in the list is: J5. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 3. Not enough free CPUs (requested: 10, actual: 4). Waiting for resources... Running active jobs... *** Tick: 6 *** Processing jobs file... The next job in the list is: J6. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 4. Not enough free CPUs (requested: 10, actual: 4). Waiting for resources... Running active jobs... *** Tick: 7 *** Processing jobs file... The next job in the list is: J7. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 5. Not enough free CPUs (requested: 10, actual: 4). Waiting for resources... Running active jobs... *** Tick: 8 *** Processing jobs file... The next job in the list is: J8. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 6. Not enough free CPUs (requested: 10, actual: 4). Waiting for resources... Running active jobs... *** Tick: 9 *** Processing jobs file... The next job in the list is: J9. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 7. Not enough free CPUs (requested: 10, actual: 4). Waiting for resources... Running active jobs... *** Tick: 10 *** Processing jobs file... The next job in the list is: J10. Adding job to jobs queue... Processing jobs queue... Current number of scheduled jobs: 8. Not enough free CPUs (requested: 10, actual: 4). Waiting for resources... Running active jobs... Job "J1" is complete. Freeing up resources. *** Tick: 11 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 8. Adding highest priority job: J4 10 2 Not enough free CPUs (requested: 4, actual: 2). Waiting for resources... Running active jobs... *** Tick: 12 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 7. Not enough free CPUs (requested: 4, actual: 2). Waiting for resources... Running active jobs... Job "J4" is complete. Freeing up resources. *** Tick: 13 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 7. Adding highest priority job: J6 4 2 Adding highest priority job: J10 6 2 Not enough free CPUs (requested: 4, actual: 2). Waiting for resources... Running active jobs... *** Tick: 14 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 5. Not enough free CPUs (requested: 4, actual: 2). Waiting for resources... Running active jobs... Job "J6" is complete. Freeing up resources. Job "J10" is complete. Freeing up resources. *** Tick: 15 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 5. Adding highest priority job: J9 4 3 Adding highest priority job: J8 2 5 Adding highest priority job: J7 4 6 Not enough free CPUs (requested: 5, actual: 2). Waiting for resources... Running active jobs... *** Tick: 16 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 2. Not enough free CPUs (requested: 5, actual: 2). Waiting for resources... Running active jobs... *** Tick: 17 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 2. Not enough free CPUs (requested: 5, actual: 2). Waiting for resources... Running active jobs... Job "J9" is complete. Freeing up resources. *** Tick: 18 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 2. Adding highest priority job: J5 5 8 Not enough free CPUs (requested: 12, actual: 1). Waiting for resources... Running active jobs... *** Tick: 19 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 1. Not enough free CPUs (requested: 12, actual: 1). Waiting for resources... Running active jobs... Job "J8" is complete. Freeing up resources. *** Tick: 20 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 1. Not enough free CPUs (requested: 12, actual: 3). Waiting for resources... Running active jobs... Job "J7" is complete. Freeing up resources. *** Tick: 21 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 1. Not enough free CPUs (requested: 12, actual: 7). Waiting for resources... Running active jobs... *** Tick: 22 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 1. Not enough free CPUs (requested: 12, actual: 7). Waiting for resources... Running active jobs... *** Tick: 23 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 1. Not enough free CPUs (requested: 12, actual: 7). Waiting for resources... Running active jobs... *** Tick: 24 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 1. Not enough free CPUs (requested: 12, actual: 7). Waiting for resources... Running active jobs... *** Tick: 25 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 1. Not enough free CPUs (requested: 12, actual: 7). Waiting for resources... Running active jobs... Job "J5" is complete. Freeing up resources. *** Tick: 26 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 1. Adding highest priority job: J3 12 12 Jobs queue is empty. Running active jobs... *** Tick: 27 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 28 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 29 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 30 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 31 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 32 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 33 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 34 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 35 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 36 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... *** Tick: 37 *** Processing jobs file... There are no more jobs in the jobs file. Processing jobs queue... Current number of scheduled jobs: 0. Jobs queue is empty. Running active jobs... Job "J3" is complete. Freeing up resources.

jobs.txt

12 J1 8 10 J2 2 1 J3 12 12 J4 10 2 J5 5 8 J6 4 2 J7 4 6 J8 2 5 J9 4 3 J10 6 2