CPU调度:控制、协调进程对CPU的竞争。
即按照一定的调度算法从就绪队列中选择一个进程,把CPU的使用权交给被选中的进程。
如果没有就绪进程,系统会安排一个系统空闲进程或idle进程。
主要解决的问题:
调度算法(选择下一个进程的规则)
何时调度
如果让被选中的进程在CPU运行;
就绪队列的改变引发了进程调度;
CPU调度的时机:
进程终止(正常或终止)
新进程创建,或一个等待进程变成就绪
当一个进程从运行态变成阻塞态
当一个进程从运行态变成就绪态
进程切换:
一个进程让出CPU,另一个进程占用CPU
批处理系统中采用的调度算法:
典型时间片大小在10ms到100ms之间;
B先等了100ms, 100+200除以2为150ms
所以I/O从等待变成就绪时,进入辅助队列,每次调度算法选择进程时先从辅助队列里面选择,直到辅助队列为空,再去从就绪队列选择;
Windows线程调度策略:
1) 主动切换
2) 抢占
3) 时间配额用完;
线程优先级提升与时间配额调整