Classic Movies and Books

Learn Software Development

All about the processes involved in software development

Search this site
Google
 

Shortest-Job-First (SJF) Scheduling

Filed Under Uncategorized | Posted on August 27, 2009




Shortest-Job-First (SJF) is a non-preemptive discipline in which waiting job (or process) with the smallest estimated run-time-to-completion, is run next. In other words, when CPU is available, it is assigned to the process that has smallest next CPU burst. The SJF scheduling is especially appropriate for batch jobs for which the run times are known in advance. Since the SJF scheduling algorithm gives the minimum average time for a given set of processes, it is probably optimal. The SJF algorithm favors short jobs (or processors) at the expense of longer ones.

Example :
Process Burst time Arrival
P1 6 0
P2 8 0
P3 7 0
P4 3 0
Gantt chart: Order P1, P2, P3, P4
| P4 | P1 | P3 | P2 |
0 3 9 16 24
Average waiting time: (0+3+16+9)/4 = 7
With FCFS: (0+6+(6+8)+(6+8+7))/4 = 10.25

Problem: SJF minimizes the average wait time because it services small processes before it services large ones. While it minimizes average wiat time, it may penalize processes with high service time requests. If the ready list is saturated, then processes with large service times tend to be left in the ready list while small processes receive service. In extreme case, where the system has little idle time, processes with large service times will never be served. This total starvation of large processes may be a serious liability of this algorithm.



| More

If you are interested in software processes, find this post informative, and want to learn more, why not subscribe ?
Subscribe in a reader
Subscribe to get updates by Email

2 Responses to “Shortest-Job-First (SJF) Scheduling”

  1. red on January 1st, 2010 4:52 pm

    can some one help me to write a c# program in FCFS example but in simple way?????????

  2. mica on February 17th, 2010 1:40 pm

    can u do me a program in java of an shortest job first(nonpreemptive,preemptive & round robin)

Leave a Reply





Bad Behavior has blocked 165 access attempts in the last 7 days.