What is SJF Scheduling


FCFS Scheduling in Operating System Priority Scheduling in Operating System

Shortest Job First (SJF) Scheduling

SJF is a full form of (Shortest job first) is a scheduling algorithm in which the process with the shortest execution time should be selected for execution next. This scheduling method can be preemptive or non-preemptive. It significantly reduces the average waiting time for other processes awaiting execution.

The job with the shortest burst time will get the CPU first. The lesser the burst time, the sooner will the process get the CPU. It is the non-preemptive type of scheduling.

sjf scheduling

Advantage of SJF Method

  • It is associated with each job as a unit of time to complete.
  • In this method, when the CPU is available, the next process or job with the shortest completion time will be executed first.
  • It is Implemented with non-preemptive policy.
  • This algorithm method is useful for batch-type processing, where waiting for jobs to complete is not critical.
  • It improves job output by offering shorter jobs, which should be executed first, which mostly have a shorter turnaround time.

Disadvantages of SJF Method

  • May suffer with the problem of starvation
  • It is not implementable because the exact Burst time for a process can't be known in advance.

Example of SJF Scheduling

In the following example, there are five jobs named as P1, P2, P3, P4 and P5. Their arrival time and burst time are given in the table below.

Process IDArrival TimeBurst TimeCompletion TimeTurn Around TimeWaiting Time

Since, No Process arrives at time 0 hence; there will be an empty slot in the Gantt chart from time 0 to 1 (the time at which the first process arrives).

According to the algorithm, the OS schedules the process which is having the lowest burst time among the available processes in the ready queue.

Till now, we have only one process in the ready queue hence the scheduler will schedule this to the processor no matter what is its burst time.

This will be executed till 8 units of time. Till then we have three more processes arrived in the ready queue hence the scheduler will choose the process with the lowest burst time.

Among the processes given in the table, P3 will be executed next since it is having the lowest burst time among all the available processes.

So that's how the procedure will go on in shortest job first (SJF) scheduling algorithm.

sjf scheduling


Avg Waiting Time = 27/5

FCFS Scheduling in Operating System Priority Scheduling in Operating System


Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Download Projects

Google Advertisements

Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs