Operating System Long Questions and AnswersHere in this section of Operating System Long Questions and Answers,We have listed out some of the important Long Questions with Answers on Shortest Job First (SJF) scheduling algorithms which will help students to answer it correctly in their University Written Exam.

Lists of Long Descriptive type Questions that may be asked in Written Exams.

  • (1) Explain Shortest Job First (SJF) scheduling algorithms with illustration.

Question-1 Explain Shortest Job First (SJF) scheduling algorithms with illustration.

Selection Criteria:

The process, that requires shortest time to complete execution, is served first.

 Decision Mode:

Non preemptive: Once a process is selected, it runs until either it is blocked for an I/O or some event, or it is terminated.

 Implementation:

This strategy can be implemented by using sorted FIFO queue. All processes in a queue are sorted in ascending order based on their required CPU bursts. When CPU becomes free, a process from the first position in a queue is selected to run.

 Example:

Consider the following set of four processes. Their arrival time and time required to complete the execution are given in following table. Consider all time values in milliseconds.

ProcessArrival Time (T0)Time required for completion (∆T)(CPU Burst Time)
P0010
P116
P232
P354


Gantt chart:

P0P2P3P1 
010121622

Initially only process P0 is present and it is allowed to run. But, when P0 completes, all other processes are present. So, process with shortest CPU burst P2 is selected and allowed to run till it completes. Whenever more than one process is available, such type of decision is taken. This procedure us repeated till all process complete their execution

Statistics:

ProcessArrival Time(T0)CPU Burst Time(∆T)Finish Time(T1)Turnaround Time(TAT=T1-T0)Waiting Time (WT=TAT-∆T)
P001010100
P116222115
P2321297
P35416117

Average Turnaround Time: (10+21+9+11)/4 = 51/4 = 12.75 ms.

Average Waiting Time: (0+15+7+7) / 4 = 29 / 4 = 7.25 ms.

Advantages:

  1. Less waiting time.
  2. Good response for short processes.

Disadvantages:

  1. It is difficult to estimate time required to complete execution.
  2. Starvation is possible for long process. Long process may wait forever.
Share with :