Knowee
Questions
Features
Study Tools

Solve following example by FCFS and SJF CPU schedulingalgorithm. Draw Gantt Chart and calculate Average Waiting Timeand Average Turnaround time.Process Arrival Time Burst TimeP0 0 10P1 1 6P2 3 2P3 5 4

Question

Solve following example by FCFS and SJF CPU schedulingalgorithm. Draw Gantt Chart and calculate Average Waiting Timeand Average Turnaround time.Process Arrival Time Burst TimeP0 0 10P1 1 6P2 3 2P3 5 4

🧐 Not the exact question you are looking for?Go ask a question

Solution

First, let's define the terms:

  • FCFS: First-Come, First-Served. This is a scheduling algorithm where the process that arrives first is the one that gets executed first.
  • SJF: Shortest Job First. This is a scheduling algorithm where the process with the shortest burst time gets executed first.
  • Gantt Chart: A type of bar chart that illustrates a project schedule.
  • Average Waiting Time: The average time that processes spend in the ready queue waiting their turn to get into the CPU.
  • Average Turnaround Time: The average time taken by a process to finish execution. It is the sum of the waiting time and the burst time.

Let's solve the problem:

  1. FCFS (First-Come, First-Served):

Gantt Chart:

|----P0----|----P1----|----P2----|----P3----| 0 10 16 18 22

Waiting time for each process:

  • P0: 0 (as it is the first process, it doesn't wait)
  • P1: 10 - 1 = 9 (it arrives at 1 but starts at 10)
  • P2: 16 - 3 = 13 (it arrives at 3 but starts at 16)
  • P3: 18 - 5 = 13 (it arrives at 5 but starts at 18)

Average Waiting Time = (0 + 9 + 13 + 13) / 4 = 8.75

Turnaround time for each process:

  • P0: 10 - 0 = 10
  • P1: 16 - 1 = 15
  • P2: 18 - 3 = 15
  • P3: 22 - 5 = 17

Average Turnaround Time = (10 + 15 + 15 + 17) / 4 = 14.25

  1. SJF (Shortest Job First):

Gantt Chart:

|----P0----|----P1----|----P2----|----P3----| 0 10 12 14 18

Waiting time for each process:

  • P0: 0 (as it is the first process, it doesn't wait)
  • P1: 10 - 1 = 9 (it arrives at 1 but starts at 10)
  • P2: 12 - 3 = 9 (it arrives at 3 but starts at 12)
  • P3: 14 - 5 = 9 (it arrives at 5 but starts at 14)

Average Waiting Time = (0 + 9 + 9 + 9) / 4 = 6.75

Turnaround time for each process:

  • P0: 10 - 0 = 10
  • P1: 12 - 1 = 11
  • P2: 14 - 3 = 11
  • P3: 18 - 5 = 13

Average Turnaround Time = (10 + 11 + 11 + 13) / 4 = 11.25

So, the average waiting time and average turnaround time are less in the SJF scheduling algorithm compared to the FCFS scheduling algorithm.

This problem has been solved

Similar Questions

You are given the Gantt chart for the Shortest Job First (SJF) scheduling algorithm. Assume all processes arrive at the same time at t=0 What is the CPU Burst time for P2?Answer 1 Question 14What is the turnaround time for P3?Answer 2 Question 14What is the CPU Burst time for P1?Answer 3 Question 14What is the waiting time for P3?Answer 4 Question 14What is the waiting time for P1?Answer 5 Question 14What is the waiting time for P4?Answer 6 Question 14What is the turnaround time for P2?Answer 7 Question 14

Q5. Consider the set of 6 processes whose arrival time and burst time are given below-Arrival time Burst timeP1 0 6P2 1 7P3 2 8P4 3 10P5 4 3P6 5 4If the CPU scheduling policy is Round Robin with time quantum = 3, calculate the average waiting time andaverage turnaround time. For the given scheduling Algorithm (a) FCFS (b) SJF (c) SRTF

Suppose that the following processes arrive for execution at the times indicated.Each process will run for the amount of time listed. In answering the questions, usenonpreemptive scheduling, and base all decisions on the information you have at the timethe decision must be made.Process Arrival Time Burst TimeP1 0.0 8P2 0.4 4P3 1.0 1a. What is the average turnaround time for these processes with the FCFSscheduling algorithm?b. What is the average turnaround time for these processes with theSJF scheduling algorithm?c. The SJF algorithm is supposed to improve performance, but notice that we choseto run process P1 at time 0 because we did not know that two shorter processes wouldarrive soon. Compute what the average turnaround time will be if the CPU is left idle forthe first 1 unit and then SJF scheduling is used. Remember that processes P1 and P2 arewaiting during this idle time, so their waiting time may increase. This algorithm could becalled future-knowledge scheduling.Exercises 3.Consider the following set of processes, with the length of the CPU burstgiven in milliseconds:Process Burst Time PriorityP1 2 2P2 1 1P3 8 4P4 4 2P5 5 3

find average turnaround time using FCFSProcess Arrival Time Burst Time wt tat ctP1 0 8 0 8 8P2 1 4 7 11 12P3 2 9 10 19 21P4 3 5 18 23 26Formula usedTATi = Wti + BTiCTi = TATiCTi+1 = Cti + BTi+iWti+1=CTi-ATi+1

Consider the given table below and find Completion time (CT), Turn-around time (TAT), Waiting time (WT), Response time (RT), Average Turn-around time and Average Waiting time in case of FCFS scheduling. Process ID Arrival time Burst time P1 2 2 P2 5 6 P3 0 4 P4 0 7 P5 7 4a.The waiting time for process P1 is 9msb.The waiting time for process P1 is 0msc.The waiting time for process P1 is 8msd.The waiting time for process P1 is 4ms

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.