MP5 Schedule Me!
|
Go to the source code of this file.
Enumerations | |
enum | scheme_t { FCFS = 0, SJF, PSJF, PRI, PPRI, RR } |
Constants which represent the different scheduling algorithms. | |
Functions | |
void | scheduler_start_up (int cores, scheme_t scheme) |
Initalizes the scheduler. | |
int | scheduler_new_job (int job_number, int time, int running_time, int priority) |
Called when a new job arrives. | |
int | scheduler_job_finished (int core_id, int job_number, int time) |
Called when a job has completed execution. | |
int | scheduler_quantum_expired (int core_id, int time) |
When the scheme is set to RR, called when the quantum timer has expired on a core. | |
float | scheduler_average_turnaround_time () |
Returns the average turnaround time of all jobs scheduled by your scheduler. | |
float | scheduler_average_waiting_time () |
Returns the average waiting time of all jobs scheduled by your scheduler. | |
float | scheduler_average_response_time () |
Returns the average response time of all jobs scheduled by your scheduler. | |
void | scheduler_clean_up () |
Free any memory associated with your scheduler. | |
void | scheduler_show_queue () |
This function may print out any debugging information you choose. |
float scheduler_average_response_time | ( | ) |
Returns the average response time of all jobs scheduled by your scheduler.
Assumptions:
float scheduler_average_turnaround_time | ( | ) |
Returns the average turnaround time of all jobs scheduled by your scheduler.
Assumptions:
float scheduler_average_waiting_time | ( | ) |
Returns the average waiting time of all jobs scheduled by your scheduler.
Assumptions:
void scheduler_clean_up | ( | ) |
Free any memory associated with your scheduler.
Assumptions:
int scheduler_job_finished | ( | int | core_id, |
int | job_number, | ||
int | time | ||
) |
Called when a job has completed execution.
The core_id, job_number and time parameters are provided for convenience. You may be able to calculate the values with your own data structure. If any job should be scheduled to run on the core free'd up by the finished job, return the job_number of the job that should be scheduled to run on core core_id.
core_id | the zero-based index of the core where the job was located. |
job_number | a globally unique identification number of the job. |
time | the current time of the simulator. |
int scheduler_new_job | ( | int | job_number, |
int | time, | ||
int | running_time, | ||
int | priority | ||
) |
Called when a new job arrives.
If multiple cores are idle, the job should be assigned to the core with the lowest id. If the job arriving should be scheduled to run during the next time cycle, return the zero-based index of the core the job should be scheduled on. If another job is already running on the core specified, this will preempt the currently running job. Assumptions:
job_number | a globally unique identification number of the job arriving. |
time | the current time of the simulator. |
running_time | the total number of time units this job will run before it will be finished. |
priority | the priority of the job. (The lower the value, the higher the priority.) |
int scheduler_quantum_expired | ( | int | core_id, |
int | time | ||
) |
When the scheme is set to RR, called when the quantum timer has expired on a core.
If any job should be scheduled to run on the core free'd up by the quantum expiration, return the job_number of the job that should be scheduled to run on core core_id.
core_id | the zero-based index of the core where the quantum has expired. |
time | the current time of the simulator. |
void scheduler_show_queue | ( | ) |
This function may print out any debugging information you choose.
This function will be called by the simulator after every call the simulator makes to your scheduler. In our provided output, we have implemented this function to list the jobs in the order they are to be scheduled. Furthermore, we have also listed the current state of the job (either running on a given core or idle). For example, if we have a non-preemptive algorithm and job(id=4) has began running, job(id=2) arrives with a higher priority, and job(id=1) arrives with a lower priority, the output in our sample output will be:
2(-1) 4(0) 1(-1)
This function is not required and will not be graded. You may leave it blank if you do not find it useful.
void scheduler_start_up | ( | int | cores, |
scheme_t | scheme | ||
) |
Initalizes the scheduler.
Assumptions:
cores | the number of cores that is available by the scheduler. These cores will be known as core(id=0), core(id=1), ..., core(id=cores-1). |
scheme | the scheduling scheme that should be used. This value will be one of the six enum values of scheme_t |