Tuesday 4 October 2011

SHORTEST JOB FIRST (SJF) :

Maintain the Ready queue in order of increasing job lengths. When a job comes in, insert it in the ready queue based on its length. When current process is done, pick the one at the head of the queue and run it.
This is provably the most optimal in terms of turnaround/response time.
But, how do we find the length of a job?
Make an estimate based on the past behavior.
  Say the estimated time (burst) for a process is E0, suppose the actual 
  time is measured to be T0.
 
  Update the estimate by taking a weighted sum of these two
  ie. E1 = aT0 + (1-a)E0
 
  in general, E(n+1) = aTn + (1-a)En    (Exponential average)
 
  if a=0, recent history no weightage
  if a=1, past history no weightage.
 
  typically a=1/2.
 
               E(n+1) = aTn + (1-a)aTn-1  +  (1-a)^jatn-j + ...
 
  Older information has less weightage
 
  
Comments: SJF is proven optimal only when all jobs are available simultaneously.
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.
Solution: Multi-Level Feedback Queques

0 comments:

Post a Comment