Process Control Management Prepared by: Dhason Operating Systems.

16
Process Control Management Prepared by: Dhason Operating Systems

Transcript of Process Control Management Prepared by: Dhason Operating Systems.

Page 1: Process Control Management Prepared by: Dhason Operating Systems.

Process Control Management

Prepared by: Dhason

Operating Systems

Page 2: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 2 of 24

Topic & Structure of the lesson

• CPU scheduling

• Preemptive scheduling algorithms

• Non-preemptive scheduling algorithms

• Calculations using preemptive scheduling algorithms

Page 3: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 3 of 24

Learning Outcomes

• 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

Page 4: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 4 of 24

CPU Scheduling

• 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

Page 5: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 5 of 24

Aims of CPU Scheduling

• 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

Page 6: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 6 of 24

Aims of Scheduling

• turnaround time- to minimize time between submission and job

completion

• throughput- to maximize the number of jobs

completed within a given time period

Page 7: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 7 of 24

Types of CPU scheduling

• 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 -

Page 8: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 8 of 24

Non-preemptive Scheduling

• 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

Page 9: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 9 of 24

Quick Review Questions

• Why is CPU scheduling important?

• What is the difference between preemptive and non-preemptive scheduling?

• Give 1 example each for a preemptive and non-

preemptive scheduling algorithm

Page 10: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 10 of 24

Calculation Keywords

• CPU utilization / burst time

• throughput

• turnaround time- average turnaround time

• waiting time- average waiting time

Page 11: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 11 of 24

Round Robin

• 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

Page 12: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 12 of 24

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

Step1:- Draw a Gantt Chart to represent timings for all processes

Round Robin

P1 P2 P3 P4 P5 P1 P5 P1 P5 P1 P1

0 2 3 5 6 8 10 12 14 15 17 19

Time Slice = 2 Milliseconds

Process

Burst Time(Milliseconds)

P1 10

P2 1

P3 2

P4 1

P5 5

Page 13: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 13 of 24

Step-3: Calculate turn-around time and average value

Round Robin

0 2 3 5 6 8 10 12 14 15 17 19

Average turn around time is (19+3+5+6+15)/5 = (48/5)=9.6

Milliseconds

TT(P2)=(2+1) = 3 TT(P3)=(3+2) = 5

TT(P4)=(5+1) = 6

TT(P5)=(10+5)=15

TT(P1)=(9+10)=19TT = Tw+TB

P1 P2 P3 P4 P5 P1 P5 P1 P5 P1 P1

Time Slice = 2 Milliseconds

Process

Burst Time(Milliseconds)

P1 10

P2 1

P3 2

P4 1

P5 5

Page 14: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 14 of 24

Round Robin

• 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)

Page 15: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 15 of 24

Q & A

Question and Answer Session

Page 16: Process Control Management Prepared by: Dhason Operating Systems.

Operating Systems

Process Control Management

Slide 16 of 24

CPU SchedulingNon-preemptive Algorithms

Next Session