Senin, 18 Maret 2013



Shortest Job First Algorithm

Shortest Job First (SJF) scheduling is a priority and Non Preventive. Non Preveentive mean here is when the allotted time a processor then the processor can not be taken the other, until the process is completed in the execution. This assumes scheduling time to complete the process known in advance. The mechanism is to schedule the process with the shortest time to completion first, thus providing high efficiency and low turn around time. In terms of time spent in the current program (job) began to enter into the system until the process is completed the system, requiring a short time. Shortest Job First (SJF) scheduling algorithm can be said to be optimal with an average waiting time is minimal.

For example, there are four processes by CPU Burst in milliseconds.


                                               Process with CPU Burst in milliseconds

Scheduling processes with the SJF algorithm (non-preventive) gant chart can be seen in the following:

                                              Gant chart algorithm SJF (non-Preventive)
 
Waiting time for P1 is 0, P2 is 26, P3 and P4 is 3 is 7 so that the average waiting time is (0 + 6 + 3 + 7) / 4 = 4 milliseconds

Another example for the algorithm Shortest Job First (SJF), for example, there are four processes (job), namely A, B, C, D with the time course of each is 8,4,4 and 4 minutes. If the processes are executed, then the turn around time for A is 8 minutes, for B is 12, for C is 16 and D is 20. If the four process using shortest job scheduling fisrt, then turn around time for B is 4, to C is 8, for D is 12 and for A is 20.

Since SJF always pay attention to the average response time is the smallest, it is very good for the interactive process. Generally interactive process has a pattern, that is waiting for orders, run the command, wait command and run the command, and so on. Problems arise when using this algorithm is not knowing the size of the job when the job log. To determine the size of the job is to make estimates or estimates based on previous behavior. The process does not come together, so that its adoption should be dynamic.

Another issue that emerged in this algorithm is that it can be as certain conditions, a job may never complete execution. Let me give an example, for example, there is a process with the elapsed time 1 hour to arrive at time 0. But at the same time every one minute and the next come the short elapsed time of 2 minutes. As a result, it could be the A never gets a small executable.
 



1 komentar: