William Stallings Computer Organization and Architecture

Download Report

Transcript William Stallings Computer Organization and Architecture

William Stallings
Computer Organization
and Architecture
Chapter 7
Operating System Support
操作系统支持
Original Author:Adrian J Pullin
Adapted by: Yanru Bao, Tianjin University
Topics
Overview
概述
Scheduling 调度
Memory Management 内存管理
Pentium II and PowerPC Memory Management
Pentium II 和 PowerPC 的内存管理
2
Overview
What is an OS?
The operating system is a program that
manages the computer’s resources,
provides services for programmers, and
schedules the execution of other
programs.
操作系统是负责管理计算机资源、为程序员提
供服务、对其他程序的执行进行调度的软件
3
Overview
Objectives and Functions
(OS的目标和功能)
Convenience 方便性
Making the computer easier to use
使计算机更加容易使用
Efficiency 有效性
Allowing better use of computer resources
使计算机资源得到更加有效的利用
4
The Operating System
as a User/Computer Interface
Layers and Views of a Computer System
5
Operating System Services (1)
Program creation 程序的建立
 provides a variety of facilities and services to
assist in creating programs, such as editors
and debuggers
 为用户进行编程时提供各种工具和服务,
如:编辑程序、调试程序
Program execution 程序执行
 a number of tasks need to be performed to
execute a program
 执行一个程序需要完成许多任务
6
Operating System Services (2)
Access to I/O devices 访问I/O设备
 each I/O device requires its own peculiar set
of instructions or control signals for operation
 每一个I/O设备都需要自己特有的指令集以及控制信
号以进行操作
Controll access to files 控制文件存取
 control include an understanding the nature
of the I/O device and the file format
 控制包括对I/O设备的性质以及文件格式的理解
7
Operating System Services (3)
System access 系统访问
 OS control access to the system as a whole
and to specific system resources
 OS对系统整体以及特殊的系统资源进行访问控制
 resolve conflicts for resource contention
 解决资源竞争冲突
8
Operating System Services (4)
Error detection and response 错误检查和响应
 OS make response
OS对错误能够作出响应
 ending the program, retrying the operation,
reporting the error
 OS能够终止出错程序、重试操作、报告错误
Accounting 统计
 Collect usage statistics for various resources
 能够对各种资源的使用情况进行统计
9
O/S as a Resource Manager(1)
A computer is a set of resources for the
movement, storage, and processing of data
and for the control of these functions. The
operating system is responsible for
managing these resources
计算机就是一组用于传送、存储和处理数据,并对
这些功能进行控制的资源的集合。
而O/S则负责管理这些资源
10
O/S as a Resource Manager(2)
O/S, as a control mechamism, is unusual in
two respects:
O/S作为控制机制有两个特殊的方面:
The O/S functions in the same way as ordinary
computer software; that is, it is a program
executed by the processor.
O/S以与其它计算机软件相同的方法起作用,即它也是
由处理器执行的程序
The O/S frequently relinquishes control and
must depend on the processor to allow it to
regain control.
O/S经常放弃控制权,并可以依靠处理器重新获得控制
权
11
O/S as a Resource Manager(3)
12
Types of Operating System(1)
Interactive 交互式O/S
 user/programmer interacts directly with the
computer, to request the execution of a job
 用户/程序员直接同计算机进行交互,请求执行作业
Batch 批处理O/S
 some programs are batched and submitted by
a computer operator
 多个程序由程序员成批的提交处理
13
Types of Operating System(2)
Single program (Uni-programming): works only
one program at a time
单道程序设计:一次只执行一个程序
Multi-programming (Multi-tasking): work on more
than one program at a time
多道程序设计:处理器一次运行多个程序
14
Early Systems(1)
Late 1940s to mid 1950s, No Operating
System
40年代末~50年代中, 没有操作系统
Programmers interacted directly with
hardware
程序员直接同硬件交互
15
Early Systems(2)
Two main problems: 早期O/S的两个主要问题
Scheduling 调度
used a sign-up sheet to reserve processor time
使用预约单预约机时
sign-up time < ? > really used time
预约时间 不一定等于真实使用时间
Setup time 安装时间
loading compiler and high-level language
program
一个作业涉及到把编译程序和高级语言程序装入内存
saving compiled program 保存已经编译的程序
linking together the object program
连接目标程序
16
Simple Batch Systems(Monitor)
 Resident Monitor program(常驻监督程序)
 Users submit jobs to operator
用户向计算机操作员提交作业
 Operator batches jobs and places them on an I device
操作员把作业成批的放到输入设备上
 Monitor controls sequence of events to be processed
监控程序对成批作业的处理顺序进行控制
 When one job is finished, control returns to Monitor
which reads next job
一个作业结束后,控制权返回监控程序,读下一个作业
 Monitor handles scheduling
监控程序负责处理调度
17
Memory Layout for Resident
Monitor
18
Job Control Language作业控制语言
 This is a special type of programming language
used to provide instructions to the monitor.
用来向监控程序提供指令的一种特殊类型的程序设计语言
 Usually denoted by $ 通常以$开头
 e.g.
$JOB
$FTN
...
Some Fortran instructions
$LOAD
$RUN
...
Some data
$END
19
Desirable Hardware Features(1)
1. Memory protection 存储器保护
 To protect the Monitor 为了保护监控程序
2. Timer 定时器
 To prevent a job monopolizing the system
为了避免单个作业独占系统
3. Privileged instructions 特权指令
 Only executed by Monitor 只能有监控程序执行
 e.g. I/O
4. Interrupts 中断
 Allows for relinquishing and regaining control
允许监控程序放弃并重新获得控制权
20
Desirable Hardware Features(2)
Processor time =
user programs time + monitor time
处理器时间 = 用户程序时间+监控程序时间
21
Multi-programmed Batch Systems
 Problem of simple batch systems 单道批处理系统的缺陷
Process =
CPU burst + I/O burst + CPU burst + I/O burst + …
I/O devices very slow (输入设备慢)
Processor often idle waiting for I/O
处理器经常等待I/O
Low CPU utilization
(CPU利用率低)
read one record
execute 100 instructions
write one record
total
CPU utilization = 3.2%
0.0015 seconds
0.0001 seconds
0.0015 seconds
0.0031 seconds
22
Multi-programmed Batch Systems
23
Multi-programmed Batch Systems
Multiprogramming (multitasking) 多任务
More than one process in memory
内存中同时处理多个任务
When one process is waiting for I/O, another
can use the CPU
当一个在等待I/O时,另一个可以使用CPU
24
Multi-Programming with
Two Programs
25
Multi-Programming with
Three Programs
26
Utilization
P238table7.2
27
Time Sharing Systems 分时系统
 Allow users to interact directly with the computer
所有用户都直接与计算机交互
 Multi-programming allows a number of users to interact
with the computer
多道程序设计允许多个用户同时与计算机交互
 Execute each user program in a short time slot
用户程序按照时间片轮流执行
 n user at one time, each user see 1/n computer speed
若n个用户请求服务,一个用户只能看到计算机有效速度的1/n
user1 user2 user3 user1 user2 user3 user1 user2 user3
28
Time Sharing Systems
The key differences between batch
multiprogramming and time sharing
批处理和时分的区别
Principal
objective
Source of
instructions
to operating
system
Batch
Multiprogramm
ing
Maximize
processor use
Job control
language
instructions
provided with
the job
Time Sharing
Minimize
response time
Commands
entered at the
terminal
29