Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

17
Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2

Transcript of Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Page 1: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Process Control Management

Prepared by: Dhason

Operating SystemsAICT004-3-2

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

Operating Systems

Process Control Management

Slide 2 of 18

Topic & Structure of the lesson

• Non-preemptive algorithms

• Calculations using non-preemptive scheduling algorithms

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

Operating Systems

Process Control Management

Slide 3 of 18

Learning Outcomes

• At the end of this lecture YOU should be able to:

- list non-preemptive scheduling algorithms

- perform calculations using non-preemptive algorithms

Page 4: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 4 of 18

Key Terms you must be able to use

If you have mastered this topic, you should be able to use the following terms correctly in your assignments and exams:

• first come first serve / first in first out• shortest job first• priority

Page 5: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 5 of 18

First Come First Serve ( FIFO / FCFS)

• the simplest CPU scheduling non-preemptive algorithm

• a process that requests for the CPU first is allocated the CPU

• the implementation of the FIFO policy is easily managed with a FIFO queue

• the average waiting time for FIFO is quite long

• once the CPU has been allocated for the process, the process keeps the CPU until termination or by requesting for I/O

Page 6: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 6 of 18

Process Burst Time(Milliseconds)

P1 10

P2 1

P3 2

P4 1

P5 5

0 10 11 13 14 19 Step2:- Calculate waiting time and average value TW(P1) = 0 TW(P2) = 10 TW(P3) = 11 Tw(P4) = 13 Tw(P5) = 14 TW(average)=( 0+10+11+13+14)/5

= 9.6 Milliseconds

Step1:- Draw a Gantt Chart to represent timings for all processesP1 P2 P4P3 P5

First Come First Serve ( FIFO / FCFS)

Page 7: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 7 of 18

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

TT = Tw+TB

Average turn around time is (10+11+13+14+19)/5 = (67/5)

=13.4 Milliseconds

TT(P2) = ( 10 + 1) = 11

TT(P3) = ( 11 + 2) = 13

TT(P4) = (13 + 1) = 14TT(P5) = (14 + 5) = 19

TT(P1) = ( 0 + 10) = 10

First Come First Serve ( FIFO / FCFS)

0 10 11 13 14 19P1 P2 P4P3 P5

Process Burst Time(Milliseconds)

P1 10

P2 1

P3 2

P4 1

P5 5

Page 8: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 8 of 18

• scheduling is done by examining the length of the next CPU burst of a process

• if the CPU is free, the next process with the smallest CPU burst time is assigned

• if two processes have the same CPU burst time, FIFO is used to break the tie

• the difficulty with SJF is to determine the length of the next process

• the advantage of this algorithm is that it is optimal; providing minimum average waiting time

Shortest Job First (SJF)

Page 9: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 9 of 18

Process Burst Time(Milliseconds)

P1 10

P2 1

P3 2

P4 1

P5 5

0 1 2 194 9

P1P2P4 P3 P5

Shortest Job First (SJF)

Step2:- Calculate waiting times and average value

TW(P1) = 9 TW(P2) = 0 TW(P3) = 2 Tw(P4) = 1 Tw(P5) = 4 TW(average) = ( 9+0+2+1+4)/5

= 3.2 Milliseconds

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

Page 10: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 10 of 18

Shortest Job First (SJF)

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

TT = Tw+TB

Average turn around time is (19+1+4+2+9)/5 = (35/5)=7

Milliseconds

TT(P2)=( 0 + 1) = 1

TT(P3)=( 2 + 2) = 4

TT(P4)=(1 + 1) = 2

TT(P5)=(4 + 5) = 9

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

P1P2P4 P3 P5

Process Burst Time(Milliseconds)

P1 10

P2 1

P3 2

P4 1

P5 5

0 1 2 194 9

Page 11: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 11 of 18

Priority

• priority is associated with each process

• the CPU is allocated to a process with the highest priority

• equal priority processes are scheduled using FIFO

• priority can be high or low; however 0 can mean high priority

• can be preemptive or non-preemptive • a problem with priority algorithm is starvation

• aging is a technique used to gradually increase the priority of a process

Page 12: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 12 of 18

0 1 13 18 1911P1P4 P2P3 P5

Priority

Step2:- Calculate waiting time and average value

TW(P1) = 1 TW(P2) = 18 TW(P3) = 11 Tw(P4) = 0 Tw(P5) = 13 TW(average)=(1+18+11+0+13)/5

= 8.6 Milliseconds

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

Process Burst Time(Milliseconds)

Priority

P1 10 3

P2 1 1

P3 2 3

P4 1 4

P5 5 2

Page 13: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 13 of 18

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

TT = Tw+TB

Average turn around time is

(11+19+13+1+18)/5 = (62/5)

=12.4 Milliseconds

TT(P2)=(18+1)=19 TT(P3)=(11+2)=13

TT(P4)=(0+1) = 1

TT(P5)=(13+5)=18

TT(P1)=(1+ 10)=11

1 13 180

Process Burst Time(Milliseconds)

Priority

P1 10 3

P2 1 1

P3 2 3

P4 1 4

P5 5 2

1911

Priority

P1P4 P2P3 P5

Page 14: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 14 of 18

Quick Review Questions

• Name three preemptive CPU scheduling algorithms

• Which of the three is the easiest to implement?

Page 15: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 15 of 18

Follow Up Assignment

• FIFO on its own is a scheduling algorithm, however FIFO is also used in other algorithms, name the algorithms.

• Which non-preemptive algorithm is optimal and why?

Page 16: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 16 of 18

Summary of Main Teaching Points

• Non-preemptive CPU scheduling algorithms are FIFO, SJF and priority.

• SJF algorithms have a shorter average waiting time compared to FIFO and priority.

• Using priority scheduling may result in some processes experiencing starvation; aging a method to overcome this problem.

Page 17: Process Control Management Prepared by: Dhason Operating Systems AICT004-3-2.

Operating Systems

Process Control Management

Slide 17 of 18

Q & A

Question and Answer Session