Os - Lecture - 04 - Process MNGNT 2
Os - Lecture - 04 - Process MNGNT 2
Os - Lecture - 04 - Process MNGNT 2
Ralph Tambala
MUST . CSIT
Lecture 4 1 / 20
Outline
1 Scheduling Goals
3 Scheduling Policies
First Come First Served
Shortest Job First
Shortest Remaining Time First
Round Robin
Priority
4 Additional Info
Lecture 4 2 / 20
Important Terms
Lecture 4 3 / 20
Scheduling Goals
Scheduling Goals
Process scheduling, also known as CPU scheduling, is the problem of
deciding when and to which processes the CPU should be allocated.
The part of the operating system concerned with this decision is called the
scheduler, and algorithm it uses is called the scheduling algorithm (policy).
The following are general goals:
Minimize waiting time
◦ Process should not wait long in the ready queue
Maximize CPU utilization
◦ CPU should not be idle
Maximize throughput
◦ Complete as many processes as possible per unit time
Minimize response time
◦ CPU should respond immediately
Fairness
◦ Give each process a fair share of CPU
Lecture 4 4 / 20
CPU Scheduling Criteria
Scheduling Policies
Lecture 4 6 / 20
Scheduling Policies First Come First Served
Lecture 4 7 / 20
Scheduling Policies First Come First Served
P1 0 8
P2 0 5
P3 0 2
Shortest job first (SJF), also known as shortest job next (SJN), is a
scheduling policy that selects for execution the waiting process with
the smallest execution time.
SJF is non-preemptive.
SJF applies FCFS if processes have the same burst time
Pros:
◦ Minimizes average wait time
Cons:
◦ May lead to starvation for long jobs. Starvation is when a process
ready to run for CPU can wait indefinitely because of low priority.
Lecture 4 9 / 20
Scheduling Policies Shortest Job First
P1 0 14
P2 0 4
P3 0 3
P4 0 7
Lecture 4 10 / 20
Scheduling Policies Shortest Remaining Time First
Lecture 4 11 / 20
Scheduling Policies Shortest Remaining Time First
P1 0 8
P2 1 2
P3 4 3
Lecture 4 12 / 20
Scheduling Policies Shortest Remaining Time First
Lecture 4 13 / 20
Scheduling Policies Round Robin
P1 0 4
P2 0 3
P3 0 5
Lecture 4 15 / 20
Scheduling Policies Round Robin
Lecture 4 16 / 20
Scheduling Policies Round Robin
Lecture 4 17 / 20
Scheduling Policies Round Robin
Priority (1)
Lecture 4 18 / 20
Scheduling Policies Priority
Priority (2)
P1 0 4 1
P2 2 3 2
P3 3 2 1
P4 8 5 3
Gantt chart
Lecture 4 19 / 20
Additional Info
Additional Info
Work again on all examples I provided in this lecture on your own.
For each:
1 Draw Gantt chart
2 Calculate average waiting time
3 Calculate average turnaround time
4 Ask for help when stuck
Let’s all participate in forum discussions!
Lecture 4 20 / 20