Exercise Ms.Reema alOraini

Slides:



Advertisements
Similar presentations
CMT603 Lecture 4 Scheduling-2. Contents Last Week –FCFS –SJF Priority scheduling Round Robin Multi Level Queues Real Systems –Linux –XP.
Advertisements

Scheduling Criteria CPU utilization – keep the CPU as busy as possible (from 0% to 100%) Throughput – # of processes that complete their execution per.
Topic : Process Management Lecture By: Rupinder Kaur Lecturer IT, SRS Govt. Polytechnic College for Girls,Ludhiana.
Process Control Management Prepared by: Dhason Operating Systems AICT
CH 5. CPU Scheduling Basic Concepts F CPU Scheduling  context switching u CPU switching for another process u saving old PCB and loading.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 2 nd Edition Chapter 6a: CPU Scheduling.
CPU Scheduling Algorithms
Exercise (5).
Scheduling Chap 2. Scheduling Introduction to Scheduling (1) Bursts of CPU usage alternate with periods of I/O wait –a CPU-bound process –an I/O bound.
Exercise (4). Exercise Assume the following jobs are executed with one processor, with the jobs arriving in the order listed in the table. – Suppose a.
CPU Scheduling Basic Concepts. Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor.
Scanf n, a, b /* I-O wait */ for (i=1; i
Process Control Management
CS340d: Operating Systems
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.
Process CPUArrival Time P P2 3 0 P3 3 0 The Gantt Chart for the schedule is: Waiting time for P1 = (7-7)=0; P2 = (0-0)=0; P3 = (3-0)
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 6: CPU Scheduling.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
CPU Scheduling Algorithms CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Chapter 5: CPU Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU Scheduling Optimization of CPU scheduling implies
CPU SCHEDULING.
Chapter 5a: CPU Scheduling
CPU Scheduling Algorithms
Priority Scheduling Example
CPU scheduling 6. Schedulers, CPU Scheduling 6.1. Schedulers
Process Scheduling B.Ramamurthy 9/16/2018.
Scheduling (Priority Based)
CPSC 457 Operating Systems
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
CPU Scheduling Basic Concepts Scheduling Criteria
CPU Scheduling G.Anuradha
Chapter 6: CPU Scheduling
Lecture 16 Syed Mansoor Sarwar
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Operating Systems Lecture 15.
Operating System Concepts
3: CPU Scheduling Basic Concepts Scheduling Criteria
Chapter5: CPU Scheduling
COT 4600 Operating Systems Spring 2011
Chapter 5: CPU Scheduling
Chapter 6: CPU Scheduling
Outline Scheduling algorithms Multi-processor scheduling
Chapter 5: CPU Scheduling
CGS 3763 Operating Systems Concepts Spring 2013
Chapter 5: CPU Scheduling
Lecture 2 Part 3 CPU Scheduling
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 2/23/2019.
Process Scheduling B.Ramamurthy 4/19/2019.
CPU SCHEDULING SIMULATION
Shortest-Job-First (SJR) Scheduling
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Process Scheduling B.Ramamurthy 5/7/2019.
CPU SCHEDULING CPU SCHEDULING.
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
Scheduling 21 May 2019.
CPU Scheduling ( Basic Concepts)
Chapter 6: CPU Scheduling
CPU Scheduling.
CPU Scheduling: Basic Concepts
Module 5: CPU Scheduling
Chapter 5: CPU Scheduling
Presentation transcript:

Exercise Ms.Reema alOraini CPU SCHEDULING Exercise Ms.Reema alOraini

Burst Time (millisecond) Question 1 Consider the following set of processes: Draw the Gantt Chart that illustrates the execution of these processes using preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer P1

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 1 P1

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 P2 had higher priority so it will be execution Timer 2 P1 P2 2

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 At time 3 p2 is finished with execution Timer 3 P1 P2 2 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 So p1 will be continue execution Timer 3 P1 P2 P1 2 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 4 P1 P2 P1 2 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 5 P1 P2 P1 2 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 6 P1 P2 P1 2 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 At time 7 p1 is finished with execution And p3 does not arrive yet Timer 7 P1 P2 P1 2 7 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 P3 is arrive so it will be execution Timer 8 P1 P2 P1 P3 8 2 7 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 9 P1 P2 P1 P3 8 2 7 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 At time 10 p3 is finished with execution Timer 10 P1 P2 P1 P3 8 2 7 10 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 P3 8 5 TAT for p1 = 7-0=7 P1 P2 P1 P3 2 7 8 10 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 TAT for p2 = 3-2=1 P1 P2 P1 P3 2 7 8 10 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 TAT for p3 = 10-8=2 P1 P2 P1 P3 2 7 8 10 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 WT for p1=7-6=1 P1 P2 P1 P3 2 7 8 10 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 WT for p2=1-1=0 P1 P2 P1 P3 2 7 8 10 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 WT for p3=2-2=0 P1 P2 P1 P3 2 7 8 10 3

preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 7 P2 2 3 P3 8 5 P1 P2 P1 P3 Average TAT=(7+1+2)/3=3.3 Average WT=(1+0+0)/3=0.33 2 7 8 10 3

Burst Time (millisecond) Question 1 Consider the following set of processes: Draw the Gantt Chart that illustrates the execution of these processes using NON- preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer P1

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 1 P1

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 2 P1

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 3 P1

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 4 P1

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 5 P1

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer At time 6 p1 finished execution 6 P1 P2 6

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer At time 7 p2 finished execution 7 P1 P2 6 7

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer At time 8 p3 will be execution 8 P1 P2 6 7 8

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 9 P1 P2 p3 6 7 8

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority P1 6 1 P2 2 3 P3 8 5 Timer 10 P1 P2 p3 6 7 8 10

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 P3 8 5 TAT for p1 = 6-0=6 P1 P2 p3 6 7 8 10

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 P3 8 5 TAT for p2 = 7-2=5 P1 P2 p3 6 7 8 10

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 P3 8 TAT for p3 = 10-8=2 P1 P2 p3 6 7 8 10

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 P3 8 WT for p1 = 6-6=0 P1 P2 p3 6 7 8 10

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 P3 8 WT for p2= 5-1=4 P1 P2 p3 6 7 8 10

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 4 P3 8 WT for p3=2-2=0 P1 P2 p3 6 7 8 10

Non-preemptive Priority algorithm Processes Arrival time Burst Time (millisecond) Priority Turnaround time Waiting time P1 6 1 P2 2 3 5 4 P3 8 Average TAT=(6+5+2)/3=4.33 Average WT=(0+4+0)/3=1.33 P1 P2 p3 6 7 8 10

D. For the given set of processes , which algorithm is better? Why? Non-preemptive Priority algorithm preemptive Priority algorithm Average TAT=(6+5+2)/3=4.33 Average WT=(0+4+0)/3=1.33 Average TAT=(7+1+2)/3=3.3 Average WT=(1+0+0)/3=0.33 By Comparing Waiting Time and Turnaround Time So , the Preemptive algorithm is better

Burst Time (millisecond) Question 2 Consider the following set of processes: Draw the Gantt Chart that illustrates the execution of these processes using Round-Robin algorithm where time quantum=5 millisecond. Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3

Round-Robin algorithm where time quantum=5 millisecond. Timer Queue : p1 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

Round-Robin algorithm where time quantum=5 millisecond. Timer 1 Queue : p1 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

Round-Robin algorithm where time quantum=5 millisecond. Timer 2 Queue : p1 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

Round-Robin algorithm where time quantum=5 millisecond. Timer 3 Queue : P1 p2 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

Round-Robin algorithm where time quantum=5 millisecond. Timer 4 Queue : P1 p2 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

Round-Robin algorithm where time quantum=5 millisecond. Timer 5 Queue : P1 P2 p1 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1 5

Round-Robin algorithm where time quantum=5 millisecond. Timer 6 Queue : P1 P2 p3 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6-5=1 P1 P2 5 6

Round-Robin algorithm where time quantum=5 millisecond. Timer 7 Queue : P1 P2 p3 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6-5=1 P1 P2 P1 5 7 6

Round-Robin algorithm where time quantum=5 millisecond. Timer 8 Queue : P1 P2 p3 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6-5=1 P1 P2 P1 P3 5 6 7

Round-Robin algorithm where time quantum=5 millisecond. Timer 9 Queue : P1 P2 p3 Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6-5=1 P1 P2 P1 P3 5 6 7 9

Round-Robin algorithm where time quantum=5 millisecond. Processes Arrival time Burst Time (millisecond) Waiting Time P1 6 P2 2 1 P3 WT for p1=(0-0)+(6-5)=1 P1 P2 P1 P3 5 6 7 9

Round-Robin algorithm where time quantum=5 millisecond. Processes Arrival time Burst Time (millisecond) Waiting Time P1 6 1 P2 2 P3 WT for p2=(5-2)=3 P1 P2 P1 P3 5 6 7 9

Round-Robin algorithm where time quantum=5 millisecond. Processes Arrival time Burst Time (millisecond) Waiting Time P1 6 1 P2 2 3 P3 WT for p3=(7-6)=1 P1 P2 P1 P3 5 6 7 9

Round-Robin algorithm where time quantum=5 millisecond. Processes Arrival time Burst Time (millisecond) Waiting Time P1 6 1 P2 2 3 P3 Average WT =(1+3+1)/3 =1.67 P1 P2 P1 P3 5 6 7 9

Burst Time (millisecond) Draw the Gantt Charts that illustrates the execution of these processes using FCFS algorithm , preemptive SJF and Non- preemptive SJF Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 1 P1

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 2 P1

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 3 P1

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 4 P1

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 5 P1

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6 P1 P2 6

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 7 P1 P2 6 7

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 8 P1 P2 P3 6 7

The FCFS algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 9 P1 P2 P3 6 7 9

The FCFS algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 P1 P2 P3 WT for p1 =0-0=0 6 7 9

The FCFS algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 P1 P2 P3 WT for p2 =6-2=4 6 7 9

The FCFS algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 4 P3 P1 P2 P3 WT for p3 =7-6=1 6 7 9

The FCFS algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 4 P3 P1 P2 P3 Average WT =(0+4+1)/3=1.67 6 7 9

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 P1

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 1 P1

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 2 P2 shorter than p1 P1 P2 2

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 3 6-2=4 P1 P2 P1 2 3

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 4 6-2=4 P1 P2 P1 2 3

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 5 6-2=4 P1 P2 P1 2 3

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 6 6-2=4 P1 P2 P1 2 3

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 7 6-2=4 P1 P2 P1 P3 2 3 7

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 8 6-2=4 P1 P2 P1 P3 2 3 7

The preemptive SJF (short job first) algorithm Gantt Chat is : Timer Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 9 6-2=4 P1 P2 P1 P3 2 3 7 9

The preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 WT for p1 =(0-0)+(3-2)=1 P1 P2 P1 P3 2 3 7 9

The preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 1 P2 2 P3 WT for p2= 2-2=0 P1 P2 P1 P3 2 3 7 9

The preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 1 P2 2 P3 WT for p3=7-6=1 P1 P2 P1 P3 2 3 7 9

The preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 1 P2 2 P3 Average WT=(1+0+1)/3=0.67 P1 P2 P1 P3 2 3 7 9

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer P1

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 1 P1

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 2 P1

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 3 P1

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 4 P1

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 5 P1

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 6 P2 is shorter than p3 P1 P2 6

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 7 P1 P2 6 7

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 8 P1 P2 P3 6 7

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) P1 6 P2 2 1 P3 Timer 9 P1 P2 P3 6 7 9

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 WT for p1=0-0=0 P1 P2 P3 6 7 9

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 P3 WT for p2=6-2=4 P1 P2 P3 6 7 9

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 4 P3 WT for p3=7-6=1 P1 P2 P3 6 7 9

The Non-preemptive SJF (short job first) algorithm Gantt Chat is : Processes Arrival time Burst Time (millisecond) Waiting time P1 6 P2 2 1 4 P3 Average WT=(0+4+1)/3=1.67 P1 P2 P3 6 7 9

Question 2 cont. D. For the given set of processes and algorithms which algorithm is better? Why? preemptive SJF (short job first) algorithm Non-preemptive SJF (short job first) algorithm FCFS algorithm Average WT =(0+4+1)/3= 1.67 Average WT=(1+0+1)/3=0.67 Average WT=(0+4+1)/3=1.67 By Comparing Waiting Time So , the Preemptive SJF algorithm is better