Here 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.

 Process Arrival Time (T0) Time required for completion (∆T)(CPU Burst Time) P0 0 10 P1 1 6 P2 3 2 P3 5 4

Gantt chart:

 P0 P2 P3 P1 0 10 12 16 22

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:

 Process Arrival Time(T0) CPU Burst Time(∆T) Finish Time(T1) Turnaround Time(TAT=T1-T0) Waiting Time (WT=TAT-∆T) P0 0 10 10 10 0 P1 1 6 22 21 15 P2 3 2 12 9 7 P3 5 4 16 11 7

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.