1 / 23

CPU algorithms

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

doris
Download Presentation

CPU algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CPU algorithms

  2. 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 • Average waiting time :- Average waiting time of all the process

  3. Criteria's to be used • Turnaround time = CPU Burst Time + Waiting time • Waiting time = Turnaround time - CBT • Average waiting time= Waiting time / count of total processes • Throughput time = Total burst time / total count of processes

  4. Example Process Burst time 0 80 1 20 2 10 3 20 4 50

  5. Gantt Chart

  6. Turnaround time for process p3 CPU burst time + waiting time = 80 + 20 + 10 + 20 = 130.

  7. Waiting time for all the processes • Waiting Time = Turnaround time – CBT • For 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.

  8. Average waiting time • Hence the average waiting time = (0+80+100+110+130)/5 • = 84 ms.

  9. Throughput time • Throughput time = Total burst time / total count of processes • = 180/5 • = 36 Milliseconds

  10. Example 2 Process Burst time 0 80 1 20 2 10 3 20 4 50 • Arrival time = 0

  11. 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?

  12. Gantt Chart

  13. Turnaround time for process P4 • The turnaround time for process P4 is = 100. • 10+20+20+50

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

  15. Example 3 p CBT Arrival Time 0 80 0 1 20 10 2 10 10 3 20 80 4 50 85 Draw gantt chart using SJF NON-Preemeptive

  16. Excercise • a. Suppose a system uses RR scheduling Quantum of 15 . Create a Gantt chart illustrating the execution of these processes? • b. What is the turnaround time for process p3? • c. What is the average wait time for the processes?

  17. Gantt Chart p CBT Arrival Time 0 80 0 1 20 10 2 10 10 3 20 80 4 50 85

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

  19. Waiting time • Waiting 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.

  20. Average waiting time • average waiting time is (0+5+20+30+40)/5 = 22 sec.

  21. Do it Yourself p CBT priority Arrival Time 0 80 0 0 1 20 10 0 2 10 10 0 3 20 80 0 4 50 85 0

  22. Calculate turnaround time of p3 for FCFS, SJF, RR(Quantum =10), Priority • Waiting time for each process for each FCFS,SJF,RR,Priority

More Related