计算机操作系统原理6

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

waiting time for this is not minimal, and may vary substantially if process CPU-burst times vary greatly. The cause is the short process behind long process. This effect may result in lower CPU and device utilization than might be possible if shorter allowed to go first.
Operating System Concepts
6.2
wency@cuit.edu.cn 2010
6.1 Basic Concepts (1)
--CPU Scheduler CPU scheduler -- Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. CPU scheduling decisions may take place when a process:
P1 P2 P3 P4 0 2 4 5 7 4 1 4
SJF (non-preemptive)
Average waiting time: (0 + 24 + 27)/3 = 17
Operating System Concepts 6.8 wency@cuit.edu.cn 2010
6.3.1 FCFS Scheduling
Suppose that the processes arrive in the order:
6.1 Basic Concepts (2)
--CPU Scheduler Nonpreemptive scheduling – once CPU has been allocated to a process, it keeps CPU until it release the CPU either by terminating or by switching to the waiting state. Preemptive scheduling – scheduler can switch CPU from a running process to another according to the policy.
SJF is optimal –gives minimum average waiting time for
a given set of processes. SJF is used frequently in long-term scheduling, and can not be implemented in CPU-scheduling.
Available policies – such as time slice, priority, and
shortest-job first Requires special hardware support and has an effect on the design of operating system kernel. Can be used in all circumstances.


their execution per time unit. Turnaround time – amount of time (from submission to completion) to execute a particular process. Waiting time – amount of time a process has been waiting in the ready queue. Response time – amount of time it takes from when a request was submitted until the first response is produced Optimization Criteria -- Max CPU utilization, Max throughput, Min turnaround time, Min waiting time, and Min response time
Operating System Concepts 6.5 wency@cuit.edu.cn 2010
6.2 Scheduling Criteria
CPU utilization – keep the CPU as busy as possible.
Throughput – the number of processes that complete
P2 , P3 , P1 .
(1)
The Gantt chart for the schedule is:
P2 0 3 P3 P1
6
30
Waiting time for P1 = 6; P2 = 0; P3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3 This is much better than previous case. Thus average
Chapter 6: CPU Scheduling
Basic Concepts Scheduling Criteria Scheduling Algorithms Real-Time Scheduling
Process Scheduling Models *
Operating System Concepts
Operating System Concepts 6.4 wency@cuit.edu.cn 2010
6.1 Basic Concepts (2)
--Dispatcher
Dispatcher -- gives control of the CPU to the
process selected by the short-term scheduler; this involves: switching context switching to user mode jumping to the proper location in the user program to restart that program Dispatch latency – the time it takes for the dispatcher to stop one process and start another running.
There is no way to know the length of the next CPU burst.
Operating System Concepts 6.10 wency@cuit.edu.cn 2010
6.3.2 SJF Scheduling (1)
Example of Non-Preemptive SJF Process Arrival Time Burst Time
6.3.1 FCFS Scheduling
FCFS –whichever requests CPU first is allocated the CPU
first. Implemented as a FIFO queue. Average waiting time is often quite long. example Process Burst Time
Priority Scheduling Round-Robin Scheduling Multilevel Queue Scheduling Multilevel Feedback Queue Scheduling
Operating System Concepts
6.7
wency@cuit.edu.cn 2010
6.6 wency@cuit.edu.cn 2010
Operating System Concepts
6.3 Scheduling Algorithms
First-Come, First-Served (FCFS) Scheduling
Shortest-Job-First (SJF) Scheduling
Operating System Concepts 6.9 wency@cuit.edu.cn 2010
6.3.2 SJF Scheduling
SJF -- Associate with each process the length of its next
CPU burst. Use these lengths to schedule the process with the shortest time. Two schemes:
nonpreemptive – once CPU given to the process it can not
be preempted until completes its CPU burst. preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the ShortestRemaining-Time-First (SRTF).
Scheduling modes -- Scheduling under 1 and 4 is nonpreemptive. All other scheduling is preemptive.
Operating System Concepts 6.3 wency@cuit.edu.cn 2010
P1 P2 P3 24 3 3
Suppose that the processes arrive at time 0, in the order:
P1 , P2 , P3 , the Gantt Chart for the schedule is:
P1 0 24 P2 27 P3 30
Waiting time for P1 = 0; P2 = 24; P3 = 27
6.1
wency@cuit.edu.cn 2010
Leabharlann Baidu
6.1 Basic Concepts
The
objective of multiprogramming is to maximum CPU utilization with several processes running at all times. In uniprocessor system, only one process may run at a time. Any other processes must wait until CPU is free and can be rescheduled. Scheduling is a fundamental OS function. As one of the primary computer resource, CPU scheduling is central.
1. Switches from running to waiting state. 2. Switches from running to ready state. 3. A high priority switches from waiting to ready. 4. Terminates.
相关文档
最新文档