Ch 9 –Scheduling
第九章 单处理器调度
学习目标:
1.了解长程、中程和短程调度的区别
2.评估不同调度策略的性能
如图9.1,多道程序设计的关键是调度,典型的调度有以上四种。
调度关系体现为:
调度决定了那个进程须等待,那个进程能继续运行。本质上说,调度属于队列管理(managing queues)问题,用于在排队环境中减少演出并优化性能。
9.1.1短程调度
又被称作dispatcher( 分派程序),使用最频繁,精确地决定下次执行那个进程。当当前进程阻塞或前瞻当前运行进程的时,调用短程调度程序。
比如有:时钟中断,I/O中断,操作系统调用,信号。
9.2.1短程调度规则
短程调度的主要目标是,按照优化系统一个或多个方面行为的方式,来分配处理器时间。常用规则有:
9.2.3Selection Function & Decision Mode
调度函数和决策模式
关于调度函数,有三个重要参数
w = time spent in system so far, waiting
e = time spent in execution so far
s = total service time required by the process, including e; generally, this quantity must be estimated or supplied by the user.
决策模式Decision Mode分为
非抢占Non-preemptive
一旦进程处于运行状态,就不断执行直到终止。
抢占preemptive
正在运行进程可能呗操作系统中断,并转为就绪态。
虽然抢占策略会导致较大开销,但是能为所有进程提供较好服务,避免了任何一个进程长时间等待的情形。
周转时间和归一化时间
Turnaround Time (Tr) is service time + wait time
Normalized Turnaround Time (Tr / Ts) – ratio to actual service time
一般来说,进程执行的时间越长,可以容忍的延迟时间越长。
Bigger values indicate additional wait time with respect to execution time
下面我们分析一下几种不同的selection function
First-Come-First-Served (FCFS)
simplest 最简单
also known as FIFO
When the current process ceases to execute, the longest process in the Ready queue is selected优先选择Ready queue 中等待时间最长的进程
对于长进程更有优势(Normalized Turnaround更小),对短进程不友好。
另一个点,对于处理器密集型友好,对I/O密集型不友好。
为改善FCFS的不足,可以使用:
Round Robin轮转法
Uses preemption based on a clock
Also known as time slicing
Shortest Process Next(SPN)
Nonpreemptive policy
Shortest expected processing time is selected next
Possibility of starvation for longer processes
Disadvantage:
Need to know the required processing time of each process
If estimate is substantially under actual running time, the system may abort the job
这个文本编辑器
有问题!
未完待续