P 3 = 27 平均等待时间Average waiting time.ppt
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Operating Systems
5.19
X.J.Lee ©2012
最优化标准 Optimization Criteria
Max CPU utilization Max throughput Min turnaround time Min waiting time Min response time
Operating Systems
5.7
X.J.Lee ©2012
Operating Systems
< CPU区间与I/O区间的交替序列 Alternating Sequence of CPU And I/O Bursts
5.8
X.J.Lee ©2012
CPU区间分布 CPU burst distribution
Operating Systems
5.9
X.J.Lee ©2012
Operating Systems
< CPU区间时间直方图 Histogram of CPU-burst Times
5.10
X.J.Lee ©2012
2. CPU 调度程序 CPU Scheduler
CPU调度程序 CPU Scheduler
Operating Systems
5.18
X.J.Lee ©2012
响应时间 Response time
从一个请求被提交到产生首次响应所需时间,而不是到输出的时间(对 于分时环境)
– amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)
The criteria include the following:
Operating Systems
5.15
X.J.Lee ©2012
CPU利用率 CPU utilization
– keep the CPU as busy as possible.(In a real system, it should range from 40 percent to 90 percent.)
Operating Systems
5.17
X.J.Lee ©2012
等待时间 Waiting time
进程在就绪队列等待的时间 amount of time a process has been waiting in the ready queue.
CPU调度算法不会影响进程执行或I/O的时间,只会影响其花在就绪队列 的时间
我们考虑各种调度算法时,就绪队列的实现可能是FIFO队列、优先级 队列、树或者是简单的无序链接列表
When we consider the various scheduling algorithms, a ready queue may be implemented as a FIFO queue, a priority queue, a tree, or simply an unordered linked list.
等待就绪 Switches from waiting to rea4diys. nonpreemptive.
终止 Terminates.
All other scheduling is preemptive.
Operating Systems
5.13
X.J.Lee ©2012
非剥夺式调度 nonpreemptive scheduling
剥夺式调度会付出代价
preemptive scheduling incurs a cost
考虑两个进程共享数据的情况。必须有新的机制以协调对共享数 据的访问
Consider the case of two process sharing data. New mechanisms are needed to coordinate access to shared data.
尽管CPU区间的分布因进程和计算机而有很大变化,但一般具有类似 图示的频率曲线。通常该曲线具有许多短CPU区间和少量的长CPU区 间
Although the durations CPU bursts vary greatly by process and by computer, they tend to have a frequency curve similar to that shown in Figure. The curve is generally with many short CPU bursts, and a few long CPU bursts.
吞吐量 Throughput
– # of processes that complete their execution per time unit
Operating Systems
5.16
X.J.Lee ©2012
周转时间 Turnaround time
执行一个特定进程所需的时间 – amount of time to execute a particular process. 包含以下时间:等待进入内存、在就绪队列的等待、在CPU上执行 以及I/O时间 It is the sum of the periods spent waiting to get into memory, waiting in ready queue, executing on the CPU, and doing I/O.
CPU调度决策可能发生在以下时机,当一个进程:
CPU scheduling decisions may take plபைடு நூலகம்ce when a process:
运行等待 Switches from running to waiting state.
运行就绪 Switches from running to ready state. Scheduling under 1 and
分派程序停止一个进程并启动另外一个进程所需的时间
– time it takes for the dispatcher to stop one process and start another running.
Operating Systems
5.12
X.J.Lee ©2012
4. Preemptive Scheduling 剥夺式调度
切换上下文 switching context 切换到用户模式 switching to user mode 跳转到用户程序的正确位置以重启该程序
jumping to the proper location in the user program to restart that program
分派延时 Dispatch latency
在内存中的进程中选择就绪进程,并讲CPU分配给其中之一
Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them.
就绪队列 ready queue
3.1基本概念 Basic Concepts 3.2调度标准 Scheduling Criteria 3.3调度算法 Scheduling Algorithms 3.4 实时调度 Summary 小结
Operating Systems
5.4
X.J.Lee ©2012
第3章 CPU调度 & 死锁
Chapter 3: CPU Scheduling & Deadlocks
3.1基本概念 Basic Concepts 3.2调度标准 Scheduling Criteria 3.3调度算法 Scheduling Algorithms 3.4 实时调度 Summary 小结
Operating Systems
5.5
X.J.Lee ©2012
3.1 ■基本概念 Basic Concepts
1. CPU-I/O 区间循环 CPU-I/O Burst Cycle 2. CPU调度程序 CPU Scheduler 3. 分派程序 Dispatcher 4. 剥夺式调度 Preemptive Scheduling
Operating Systems
5.6
X.J.Lee ©2012
1. CPU-I/O 区间循环 CPU-I/O Burst Cycle
通过多道程序设计提高CPU利用率
Maximum CPU utilization obtained with multiprogramming
CPU-I/O 区间循环 CPU–I/O Burst Cycle
进程执行过程由CPU执行和I/O等待的循环组成 – Process execution consists of a cycle of CPU execution and I/O wait. (Figure)
Operating Systems
5.14
X.J.Lee ©2012
3.2 ■调度标准 Scheduling Criteria
不同的调度算法具有不同的属性并可能有利于某一类进程
Different CPU-scheduling algorithms have different properties and may favor one class of processes over another.
Operating Systems
5.11
X.J.Lee ©2012
3. Dispatcher 分派程序
分派程序模块将CPU控制交给由短程调度程序选中的进程, 包括:
Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves:
操作系统
Operating Systems
李旭健 XJLee@163.com
Autumn 2012
第3章 CPU调度 & 死锁
Chapter 3: CPU Scheduling & Deadlocks
new admitted
interrupt
exit terminated
ready
running
一旦CPU分配给了一个进程,则该进程保持CPU直到其因为终止 或切换到等待状态而释放CPU
once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state.
scheduler dispatch
I/O or event completion
waiting
I/O or event wait
/blocked
5 状态模型
Operating Systems
5.3
X.J.Lee ©2012
第3章 CPU调度 & 死锁
Chapter 3: CPU Scheduling & Deadlocks
The CPU-scheduling algorithm does not affect the amount of time during which a process executes or does I/O; it affects only the amount of time that a process spends waiting in the ready queue.
Operating Systems
5.20
X.J.Lee ©2012
3.3 ■ Scheduling Algorithms 调度算法
1.先来先服务调度 First-Come, First-Served Scheduling 2.短作业优先调度 Shortest-Job-First Scheduling 3.优先级调度 Priority Scheduling 3* 高响应比优先 Highest Response Ratio First 4.循环(轮转)调度 Round-Robin Scheduling 5.多级队列调度 Multilevel Queue Scheduling 6.多级反馈队列调度 Multilevel Feedback Queue Scheduling