Operating-Systems-Notes

Scheduling

Operating System perform scheduling in the following simple ways:

CPU Scheduler

Context switch, enter user mode, set PC and go! <= Thread is dispatched on CPU.

“Run-to-completion” Scheduling

Scheduling algorithms:

1. First Come First Serve (FCFS)

runqueue = queue(FIFO)

If T1, T2, T3 arrive in the given order and T1 has execution time 1s, T2 10s and T3 1s then :

2. Shortest Job First (SJF)

runqueue = ordered(queue)

//or

runqueue = tree()

For SJF,

Preemptive Scheduling

T2 arrives first.

preemptive

Priority Scheduling

priority

runqueue = per priority_queue()

//or 

runqueue = tree() ordered on priority

3. Round-Robin Scheduling

rr1

rr2

rr3

4. Shortest Remaining Time First (SRTF)

Timeslicing

rr4

Advantages

Disdvantages

How long should a timeslice be be?

For CPU bound tasks:

cputs

For I/O bound tasks:

iots

Summary