程序代写代做代考 scheme Scheduler

Scheduler

priority queue
Core II
Core III
Core IV
Scheduler
Core I
Scheduler

Job & Core
Core
isFree? which Job?

Your Job
void scheduler_start_up(int, scheme_t);
int scheduler_new_job(int, int, int, int);
int scheduler_job_finished(int, int, int);
int scheduler_quantum_expired(int, int);
float scheduler_average_turnaround_time();
float scheduler_average_waiting_time();
float scheduler_average_response_time();
void scheduler_clean_up();

• • • • • •
FCFS: First Come First Serve
SJF: Shortest Job First (Non-Preemptive ) PSJF: Preemptive Shortest Job First
PRI: Priority (Non-Preemptive )
PPRI: Preemptive Priority
RR: Round Robbin
Shceme

• •

scheduler_start_up
Init cores
Init queues according to scheme
Need your own compare functions



• • • •
Compare Functions comp_fcfs( void* job1, void* job2):
First come first serve
Get arrival time from job1, job2 arrival1 < arrival2: return -1 arrival1 > arrival2: return 1 otherwise return 0

• •
New job arrives Find free cores
Scheduler_new_job
If any, assign jobs. •

If non-preemptive
Put job in queue •

If preemptive

Find a core

• • •
If a job is finished
Set the flag of core as free schedule a new job from queue
Scheduler_job_finished

Scheduler_quantum_expired
• • •
Only called when scheme is RR Put the job back to the queue Schedule a new job from queue