When is SJF worse than FCFS?

ぃ、小莉子 提交于 2019-12-12 02:57:29

问题


In operating systems of supercomputers, which handles a big quantity of tasks at the same time, is there any situation when SJF policy is taking longer than FCFS policy, speaking of waiting time metric?

It can be assumed that more than one core are present in the system.


回答1:


First I thought that it is not possible, then I took some time and finally arrived at this result:

Yes it can be.

Suppose that ready queue is filled with processes with equal burst times(all = x):

Process    Burst time
 P1          x
 P2          x
 P3          x
 P4          x
 .           .
 .           .
 .           .
 Pn          x

Now in this case what FCFS would do, the process that would come first will be allocated the CPU and then the next process which comes first will be allocated the CPU and so on without wasting any time.

But what SJF will do is :it will first find the job with the shortest burst time from the available jobs in the ready queue which in this case is wastage of time as all have equal burst times and SJF would end up traversing the ready queue without any fruitful result.



来源:https://stackoverflow.com/questions/31114679/when-is-sjf-worse-than-fcfs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!