Process Control Management

Download Report

Transcript Process Control Management

Operating Systems
Process Control Management
Prepared by: Dhason
Topic & Structure of the lesson
Process Control Management
• CPU scheduling
• Preemptive scheduling algorithms
• Non-preemptive scheduling algorithms
• Calculations using preemptive scheduling algorithms
Operating Systems
Slide 2 of 24
Learning Outcomes
Process Control Management
• At the end of this lecture YOU should be able to:
- explain the importance of CPU scheduling
- distinguish between preemptive and
non-preemptive algorithms
- calculate waiting time and turnaround time
Operating Systems
Slide 3 of 24
CPU Scheduling
Process Control Management
•
a CPU scheduler is tasked with choosing which
process to run first from the ready queue
• a scheduling algorithm is used to choose the next
process
• scheduling is a fundamental function of an operating
system
• scheduling is done to ensure that the CPU is not
idle
Operating Systems
Slide 4 of 24
Aims of CPU Scheduling
Process Control Management
• fairness
- to make sure all processes get a fair share of
the CPU time
- to avoid starvation
•
efficiency
- to maximize CPU utilization and keep the CPU
busy close to 100% of the time
• response time
- to provide consistent response time
- to minimize response time
Operating Systems
Slide 5 of 24
Aims of Scheduling
Process Control Management
• turnaround time
- to minimize time between submission and job
completion
• throughput
- to maximize the number of jobs completed
within a given time period
Operating Systems
Slide 6 of 24
Types of CPU scheduling
Process Control Management
• preemptive and non-preemptive scheduling:
• preemptive scheduling:
- allows for processes running to be temporarily
suspended
- processes releases CPU upon receiving a command from
the operating system
- preemptive scheduling algorithm:
- round robin
-
Operating Systems
Slide 7 of 24
Non-preemptive Scheduling
Process Control Management
• non-preemptive scheduling:
- processes releases the CPU only after completion
- processes releases CPU voluntarily
- non-preemptive scheduling algorithms:
- first come first serve or first in first out
(FCFS), ( FIFO)
- shortest job first
- priority
Operating Systems
Slide 8 of 24
Quick Review Questions
Process Control Management
• Why is CPU scheduling important?
• What is the difference between preemptive and nonpreemptive scheduling?
• Give 1 example each for a preemptive and nonpreemptive scheduling algorithm
Operating Systems
Slide 9 of 24
Calculation Keywords
Process Control Management
• CPU utilization / burst time
• throughput
• turnaround time
- average turnaround time
• waiting time
- average waiting time
Operating Systems
Slide 10 of 24
Round Robin
Process Control Management
• the oldest, simplest, fairest and most widely used algorithm
• designed for time-sharing systems
• a time quantum / time slice is defined for each process
• the ready queue is treated as a circular queue
• to implement round robin, the ready queue is kept as a
first in first out queue
Operating Systems
Slide 11 of 24
Round Robin
Process Control Management
Step1:- Draw a Gantt Chart to represent timings for all
processes
P1
P2 P3 P4 P5
0
2 3
5
6
8
Step2:- Calculate waiting time
and average value
TW(P1) = (0+6+2+1)=9
TW(P2) = 2
TW(P3) = 3
Tw(P4) = 5
Tw(P5) = (6+2+2)=10
TW(average)=(9+2+3+5+10)/5
=5.8 Milliseconds
Operating Systems
P1
P5
10
P1 P5 P1 P1
12
14
15
17 19
Time Slice = 2
Milliseconds
Burst Time
Process
(Milliseconds)
P1
10
P2
1
P3
2
P4
1
P5
5
Slide 12 of 24
Round Robin
Process Control Management
Step-3: Calculate turn-around time and average value
P1
0
P2 P3 P4 P5
2
3
TT(P1)=(9+10)=19
TT(P2)=(2+1) = 3
TT(P3)=(3+2) = 5
TT(P4)=(5+1) = 6
5
P1
6
8
10
TT = Tw+TB
P5
P1 P5 P1 P1
12
TT(P5)=(10+5)=15
Average turn around time is
(19+3+5+6+15)/5 = (48/5)=9.6
Milliseconds
Operating Systems
14
15
17 19
Time Slice = 2
Milliseconds
Burst Time
Process
(Milliseconds)
P1
10
P2
1
P3
2
P4
1
P5
5
Slide 13 of 24
Round Robin
Process Control Management
• the average waiting time is usually long
• performance depends on the size of the time quantum
(10 – 100 milliseconds)
• process switching requires time; the time quantum
clock is already running
• time quantum which is set to short would result in too
many process switches and this reduces CPU efficiency
• time quantum which is too long would cause poor
response to short interactive request (would result to FIFO)
Operating Systems
Slide 14 of 24
Question and Answer Session
Process Control Management
Q&A
Operating Systems
Slide 15 of 24
Next Session
Process Control Management
CPU Scheduling
Non-preemptive Algorithms
Operating Systems
Slide 16 of 24