调度方式
FIFO(first in first out)
Nonpreemptive(不可剥夺):进程一直在CPU上run,直到阻塞或者进程结束
优点
1.代码编写简单,利于理解
缺点
1.平均等待时间长
2.短作业有可能在长作业之后,导致等待的时间变长。
Round robin(分时调度)
优点
1.对于短期作业,很快就能运行完
缺点
时间片太短:
1.代价大
2.长期作业的上下文切换时间大大增加
SJF(Shortest job first)
优点
1.Provably optimal
2.Great for short jobs
3.Small degradation for long jobs
缺点
1.可能会有很长的作业让后面的作业等待
SRTF(Shortest remainning time first)
优点
缺点
Starvation: constant arrivals of short jobs
can keep long ones from running
There is no way to know the completion time
of jobs (most of the time)
Some solutions
◼ Ask the user, who may not know any better
◼ If a user cheats, the job is killed
(优先级调度)Priority scheduling
优点
缺点
多级反馈队列(Multilevel feedback queues)
use multiple queues with different priorities
❑ Round robin at each priority level
❑ Run highest priority jobs first
❑ Once those finish, run next highest priority, etc
❑ Jobs start in the highest priority queue
❑ If time slice expires, drop the job by one level
❑ If time slice does not expire, push the job up by
one level