+ All Categories
Home > Documents > CPU algorithms

CPU algorithms

Date post: 23-Feb-2016
Category:
Upload: doris
View: 37 times
Download: 0 times
Share this document with a friend
Description:
CPU algorithms. CPU Algorithm. Turnaround time :- Amount of time to execute a particular process. Waiting time – amount of time a process has been waiting in the ready queue Throughput – No. of processes that complete their execution per time unit - PowerPoint PPT Presentation
23
CPU algorithms
Transcript
Page 1: CPU algorithms

CPU algorithms

Page 2: CPU algorithms

CPU AlgorithmTurnaround time :- Amount of time to

execute a particular process.Waiting time – amount of time a process

has been waiting in the ready queueThroughput – No. of processes that

complete their execution per time unitAverage waiting time :- Average waiting

time of all the process

Page 3: CPU algorithms

Criteria's to be usedTurnaround time = CPU Burst Time +

Waiting timeWaiting time = Turnaround time - CBTAverage waiting time= Waiting time / count

of total processesThroughput time = Total burst time / total

count of processes

Page 4: CPU algorithms

ExampleProcess Burst time0 801 202 103 204 50

Page 5: CPU algorithms

Gantt Chart

Page 6: CPU algorithms

Turnaround time for process p3CPU burst time + waiting time

= 80 + 20 + 10 + 20= 130.

Page 7: CPU algorithms

Waiting time for all the processesWaiting Time = Turnaround time – CBTFor p3

130 - 20 = 110

Waiting Time for process p0 = 0 sec.Waiting Time for process p1 = 80 sec.Waiting Time for process p2 = 100 sec.Waiting Time for process p3 = 110 sec.Waiting Time for process p4 = 130 sec.

Page 8: CPU algorithms

Average waiting timeHence the average waiting time =

(0+80+100+110+130)/5= 84 ms.

Page 9: CPU algorithms

Throughput timeThroughput time = Total burst time / total count

of processes

= 180/5= 36 Milliseconds

Page 10: CPU algorithms

Example 2Process Burst time0 801 202 103 204 50

Arrival time = 0

Page 11: CPU algorithms

Exercise Use SJF

Create a Gantt chart illustrating the execution of these processes?

What is the turnaround time for process p4?What is the average wait time for the

processes?

Page 12: CPU algorithms

Gantt Chart

Page 13: CPU algorithms

Turnaround time for process P4The turnaround time for process P4 is = 100.10+20+20+50

Page 14: CPU algorithms

Average Waiting timeWaiting time of po+p1+p2+p3+p4(100+10+0+30+50)/5 = 38 ms

Page 15: CPU algorithms

Example 3p CBT Arrival Time0 80 01 20 102 10 103 20 804 50 85

Draw gantt chart using SJF NON-Preemeptive

Page 16: CPU algorithms

Excercisea. Suppose a system uses RR scheduling Quantum of 15 .Create a Gantt chart illustrating the execution

of theseprocesses?

b. What is the turnaround time for process p3?

c. What is the average wait time for the processes?

Page 17: CPU algorithms

Gantt Chartp CBT Arrival Time0 80 01 20 102 10 103 20 804 50 85

Page 18: CPU algorithms

Turnaround time for process P3The turnaround time for process P3 is =160-80= 80 sec.

Page 19: CPU algorithms

Waiting timeWaiting time for process p0 = 0 sec.Waiting time for process p1 = 5 sec.Waiting time for process p2 = 20 sec.Waiting time for process p3 = 30 sec.Waiting time for process p4 =4 0 sec.

Page 20: CPU algorithms

Average waiting timeaverage waiting time is (0+5+20+30+40)/5

= 22 sec.

Page 21: CPU algorithms
Page 22: CPU algorithms

Do it Yourselfp CBT priority Arrival Time0 80 0 01 20 10 02 10 10 03 20 80 04 50 85 0

Page 23: CPU algorithms

Calculate turnaround time of p3 for FCFS, SJF, RR(Quantum =10), Priority

Waiting time for each process for each FCFS,SJF,RR,Priority


Recommended