william stallings computer organization and architecture

29
Original Author:Adrian J Pullin Adapted by: Yanru Bao, Tianji n University William Stallings Computer Organization and Architecture Chapter 7 Operating System Support 操操操 操操

Upload: gemma-richard

Post on 03-Jan-2016

45 views

Category:

Documents


3 download

DESCRIPTION

William Stallings Computer Organization and Architecture. Chapter 7 Operating System Support 操作系统支持. Topics. Overview 概述 Scheduling 调度 Memory Management 内存管理 Pentium II and PowerPC Memory Management Pentium II 和 PowerPC 的内存管理. Overview. What is an OS? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: William Stallings  Computer Organization  and Architecture

Original Author:Adrian J Pullin Adapted by: Yanru Bao, Tianjin University

William Stallings Computer Organization and Architecture

Chapter 7Operating System Support

操作系统支持

Page 2: William Stallings  Computer Organization  and Architecture

2

Topics

Overview 概述

Scheduling 调度

Memory Management 内存管理

Pentium II and PowerPC Memory Management

Pentium II 和 PowerPC 的内存管理

Page 3: William Stallings  Computer Organization  and Architecture

3

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.

操作系统是负责管理计算机资源、为程序员提供服务、对其他程序的执行进行调度的软件

Page 4: William Stallings  Computer Organization  and Architecture

4

Overview

Objectives and Functions (OS 的目标和功能 ) Convenience 方便性

Making the computer easier to use 使计算机更加容易使用

Efficiency 有效性Allowing better use of computer resources

使计算机资源得到更加有效的利用

Page 5: William Stallings  Computer Organization  and Architecture

5

The Operating System as a User/Computer Interface

Layers and Views of a Computer System

Page 6: William Stallings  Computer Organization  and Architecture

6

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 执行一个程序需要完成许多任务

Page 7: William Stallings  Computer Organization  and Architecture

7

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 设备的性质以及文件格式的理解

Page 8: William Stallings  Computer Organization  and Architecture

8

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 解决资源竞争冲突

Page 9: William Stallings  Computer Organization  and Architecture

9

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 能够对各种资源的使用情况进行统计

Page 10: William Stallings  Computer Organization  and Architecture

10

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 则负责管理这些资源

Page 11: William Stallings  Computer Organization  and Architecture

11

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 经常放弃控制权,并可以依靠处理器重新获得控制权

Page 12: William Stallings  Computer Organization  and Architecture

12

O/S as a Resource Manager(3)

Page 13: William Stallings  Computer Organization  and Architecture

13

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 多个程序由程序员成批的提交处理

Page 14: William Stallings  Computer Organization  and Architecture

14

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

多道程序设计:处理器一次运行多个程序

Page 15: William Stallings  Computer Organization  and Architecture

15

Early Systems(1)

Late 1940s to mid 1950s, No Operating System

40 年代末~ 50 年代中 , 没有操作系统

Programmers interacted directly with hardware

程序员直接同硬件交互

Page 16: William Stallings  Computer Organization  and Architecture

16

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 连接目标程序

Page 17: William Stallings  Computer Organization  and Architecture

17

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

监控程序负责处理调度

Page 18: William Stallings  Computer Organization  and Architecture

18

Memory Layout for Resident Monitor

Page 19: William Stallings  Computer Organization  and Architecture

19

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

Page 20: William Stallings  Computer Organization  and Architecture

20

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 允许监控程序放弃并重新获得控制权

Page 21: William Stallings  Computer Organization  and Architecture

21

Desirable Hardware Features(2)

Processor time = user programs time + monitor time

处理器时间 = 用户程序时间+监控程序时间

Page 22: William Stallings  Computer Organization  and Architecture

22

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 0.0015 secondsexecute 100 instructions 0.0001 secondswrite one record 0.0015 secondstotal 0.0031 secondsCPU utilization = 3.2%

Page 23: William Stallings  Computer Organization  and Architecture

23

Multi-programmed Batch Systems

Page 24: William Stallings  Computer Organization  and Architecture

24

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

Page 25: William Stallings  Computer Organization  and Architecture

25

Multi-Programming with Two Programs

Page 26: William Stallings  Computer Organization  and Architecture

26

Multi-Programming with Three Programs

Page 27: William Stallings  Computer Organization  and Architecture

27

Utilization P238table7.2

Page 28: William Stallings  Computer Organization  and Architecture

28

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/nuser1 user2 user3 user1 user2 user3 user1 user2 user3

Page 29: William Stallings  Computer Organization  and Architecture

29

Time Sharing Systems

The key differences between batch multiprogramming and time sharing批处理和时分的区别

Batch Multiprogramming

Time Sharing

Principal objective

Maximize processor use

Minimize response time

Source of instructions to operating system

Job control language instructions provided with the job

Commands entered at the terminal