53
Operating Systems Principles Lecture 1: Introduction 主主主 主主主

Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Embed Size (px)

Citation preview

Page 1: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Operating Systems PrinciplesLecture 1: Introduction

主講人:虞台文

Page 2: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Content The Role of Operating Systems

– Bridge the Hardware/Application Gap– Three Views of Operating Systems

Organization of Operating Systems– Structural Organization– The Hardware Interface– The Programming Interface– The User Interface– Runtime Organization

Operating System Evolution & Concepts

Page 3: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Operating Systems PrinciplesLecture 1: Introduction

The Role of Operating Systems

Page 4: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

PC Hardware Organization

Page 5: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Users ←→ Hardware

The Gap

Page 6: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Users ←→ Hardware

The Gap

Hardware capabilities are very low level• Arithmetic and logical operators• Comparison of two bit-strings• Branching, reading, and writing bytes

Hardware capabilities are very low level• Arithmetic and logical operators• Comparison of two bit-strings• Branching, reading, and writing bytes

User needs to think in terms of problem to be solved• High-level data structures and corresponding operations• Simple, uniform interfaces to subsystems,• Treat programs and data files as single entities

User needs to think in terms of problem to be solved• High-level data structures and corresponding operations• Simple, uniform interfaces to subsystems,• Treat programs and data files as single entities

Page 7: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Fills the Gap

Software

Page 8: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Fills the Gap

Software

Use software to bridge this gap• Language processors e.g.,

- assemblers, compilers, interpreters• Editors and text processors, linkers and loaders.• Application programs, utility and service programs.• Operating Systems

Use software to bridge this gap• Language processors e.g.,

- assemblers, compilers, interpreters• Editors and text processors, linkers and loaders.• Application programs, utility and service programs.• Operating Systems

Page 9: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Single CPU System

Page 10: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Single CPU System

Page 11: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

I/O Devices

I/O Devices

Page 12: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Multiprocessor Systems

Share-Memory Model

Distributed-Memory Model

Page 13: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Synchronization & Communication of CPU’s

Share-Memory Model

Distributed-Memory Modelthrough the shared memory

interconnection network required.

Page 14: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Cash Coherence Problem

Share-Memory Model

Distributed-Memory Model

Cashes do not contain different values for the same memory element.

Cashes do not contain different values for the same memory element.

Local Cash

Page 15: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Multicomputer System

Page 16: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Multicomputer System

Network Controller

Network Controller

Page 17: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Local Area Networks

Local area networks (LANs) connect computers within a building or a enterprise network.

LAN network topologies:

Ring Network Broadcast Bus

Page 18: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Wide Area Networks

A Wide Area Network (WAN) is a collection of Local Area Networks (LANs) that have been connected together.

The internet is an example of a WAN.

Page 19: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Applications/ServicesApplications/Services

OperatingSystem

OperatingSystem

What are done by OS?

Process Management– Scheduling of process– Synchronization

Memory Management– Virtual memory

Input/Output Systems– Device drivers– Spooling

File Systems Protection and Security

BareMachine

BareMachine

Page 20: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Applications/ServicesApplications/Services

OperatingSystem

OperatingSystem

Three Views of OS’s

BareMachine

BareMachine

User’s View

ApplicationProgrammer’

s View

SystemProgrammer’

s View

Page 21: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Applications/ServicesApplications/Services

OperatingSystem

OperatingSystem

User’s View

BareMachine

BareMachine

User’s View

ApplicationProgrammer’

s View

SystemProgrammer’

s View

OS is an extended machine• Abstraction — hides complexity• Provides high level operations

Page 22: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Applications/ServicesApplications/Services

OperatingSystem

OperatingSystem

Application Programmer’s View

BareMachine

BareMachine

User’s View

ApplicationProgrammer’

s View

SystemProgrammer’

s View

OS is a virtual machine• Virtualization — supports sharing• Provides virtual CPU, memory, devices

Page 23: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Applications/ServicesApplications/Services

OperatingSystem

OperatingSystem

System Programmer’s View

BareMachine

BareMachine

User’s View

ApplicationProgrammer’

s View

SystemProgrammer’

s View

OS is a resource manager• Balance overall performance with individual needs e.g., response time, deadlines

Page 24: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Operating Systems PrinciplesLecture 1: Introduction

Organization of Operating Systems

Page 25: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Structure Organization of OS

HardwareHardware

OperatingSystemKernel

OperatingSystemKernel

SystemLibrary

Applications(system & user)

User

MachineInstructions

KernelCalls

LibraryCalls

Page 26: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Modes of CPU Execution

HardwareHardware

OperatingSystemKernel

OperatingSystemKernel

SystemLibrary

Applications(system & user)

User

MachineInstructions

KernelCalls

LibraryCalls

privileged mode

nonprivileged mode

Page 27: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Supervisor Call (SVC)

HardwareHardware

OperatingSystemKernel

OperatingSystemKernel

SystemLibrary

Applications(system & user)

User

MachineInstructions

KernelCalls

LibraryCalls

privileged mode

nonprivileged modeSVC

SVCs are used to implement all kernel calls and form the basic interface btw the OS kernel and the rest of the software.

Page 28: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Hardware Interface

Applications and OS compiled into machine instructions

Interrupts and Traps allow OS to seize control

– process management (time-sharing)

– device management (I/O completion)

HardwareHardware

OperatingSystemKernel

OperatingSystemKernel

SystemLibrary

Applications(system & user)

User

HardwareHardware

OperatingSystemKernel

OperatingSystemKernel

SystemLibrarySystemLibrary

Applications(system & user)

Applications(system & user)

UserUser

SVC

Page 29: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Programming Interface

HardwareHardware

OperatingSystemKernel

OperatingSystemKernel

SystemLibrarySystemLibrary

Applications(system & user)

Applications(system & user)

UserUser

MachineI nstructions

KernelCalls

LibraryCalls

Invoking system services• Library call (nonprivileged)• Kernel call (privileged)

Page 30: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The User Interface

HardwareHardware

OperatingSystemKernel

OperatingSystemKernel

SystemLibrarySystemLibrary

Applications(system & user)

Applications(system & user)

UserUser

MachineI nstructions

KernelCalls

LibraryCalls

Text-based shell e.g., Unix, MS Dos– command interpreter– shell scripts

Graphics-based GUIe.g., Mac, MS Windows– windows– icons– menus– pointer

Page 31: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Runtime Organization

Service isa Subroutine

Service is an Autonomous Process

(client-server)

Page 32: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Operating Systems PrinciplesLecture 1: Introduction

Operating System Evolution & Concepts

Page 33: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

History of Operating Systems

The First Generation (1945–55) – Vacuum Tubes and Plugboards

The Second Generation (1955–65)– Transistors and Batch Systems

The Third Generation (1965–1980)– ICs and Multiprogramming

The Fourth Generation (1980–Present)– Personal Computers

Page 34: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The First Generation (1945–55) Vacuum Tubes and Plugboards

Page 35: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The First Generation (1945–55) Vacuum Tubes and Plugboards

Page 36: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The First Generation (1945–55) Vacuum Tubes and Plugboards

Machines of the time were so primitive that programs were often entered one bit at time on rows of mechanical switches (plugboards).

Programming languages were unknown (not even assembly languages).

Operating systems were unheard of.

Page 37: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Second Generation (1955–65) Transistors and Batch Systems

A batch system is one in which jobs are bundled together with the instructions necessary to allow them to be processed without intervention.

Often jobs of a similar nature can be bundled together to further increase economy.

Page 38: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Second Generation (1955–65) Transistors and Batch Systems

Page 39: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Second Generation (1955–65) Transistors and Batch Systems

$JOB user_spec ;identify the user for accounting purposes$FORTRAN ;load the FORTRAN compilersource program cards$LOAD ;load the compiled program$RUN ;run the programdata cards$EOJ ;end of job $JOB user_spec ;identify a new user$LOAD application$RUNData$EOJ

Page 40: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Second Generation (1955–65) Transistors and Batch Systems

Page 41: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

Memory Layout of a Batch

System

The Second Generation (1955–65) Transistors and Batch Systems

The monitor is system software that is responsible for interpreting and carrying out the instructions in the batch jobs.

When the monitor started a job, it handed over control of the entire computer to the job, which then controlled the computer until it finished.

Monitor(permanently resident)

Monitor(permanently resident)

User Space

(compilers, programs,

data, etc.)

User Space

(compilers, programs,

data, etc.)

Monitor: another name of OS.

Page 42: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Second Generation (1955–65) Transistors and Batch Systems

Advantages of batch systems – move much of the work of the operator to the computer – increased performance since it was possible for job to

start as soon as the previous job finished

Disadvantages – turn-around time can be large from user standpoint – more difficult to debug program – due to lack of protection scheme, one batch job can

affect pending jobs (read too many cards, etc) – a job could corrupt the monitor, thus affecting pending

jobs – a job could enter an infinite loop

Page 43: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Third Generation (1965–1980) ICs and Multiprogramming

Have more than one active (running) program in memory at any one time.

Why?

Page 44: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Third Generation (1965–1980) ICs and Multiprogramming

Main features of this generation

CPU and I/O Overlap

Spooling

– simultaneous peripheral operations on line

Time-sharing technique

Page 45: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Third Generation (1965–1980) ICs and Multiprogramming

The typical CPU and I/O overlap patternin a single program

Page 46: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Third Generation (1965–1980) ICs and Multiprogramming

Goal of multiprogramming Keep CPUs and and I/O devices busy.

Page 47: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Third Generation (1965–1980) ICs and Multiprogramming

CPU Bound Programs– Perform calculation most of time– Scientific computation

I/O Bound Programs– Perform I/O most of time– Commercial data processing

Page 48: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Third Generation (1965–1980) ICs and Multiprogramming

TimeSaved

Page 49: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Third Generation (1965–1980) ICs and Multiprogramming

Spooling (simultaneous peripheral operations on line).

In spooling, a high-speed device like a disk interposed between a running program and a low-speed device involved with the program in input/output.

Example: Instead of writing directly to a printer, outputs are written to the disk. – Programs can run to completion faster; and – other programs can be initiated sooner when the

printer becomes available, the outputs may be printed.

Page 50: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Third Generation (1965–1980) ICs and Multiprogramming

Time Sharing Technique A variant of multiprogramming technique. Each user has an on-line terminal. Because the user is present and interacting with the

computer, the computer system must respond quickly to user requests, otherwise user productivity could suffer.

Timesharing systems were developed to multiprogram large number of simultaneous interactive users.

Page 51: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Fourth Generation (1980–Present) Personal Computers

With the development of LSI circuits, chips, operating system entered entered in the personal computer and the workstation age.

Microprocessor technology evolved to the point that it become possible to build desktop computers as powerful as the mainframes of the 1970s.

Page 52: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Fourth Generation (1980–Present) Personal Computers

CP/M (Control Program of Microcomputers)

MS-Dos Windows Unix

GUI

Page 53: Operating Systems Principles Lecture 1: Introduction 主講人:虞台文

The Evolution

Early systems No Operating System

Batch Operating Systems

Multiprogramming Systems

Interactive operating Systems

Personal Computer and Workstation Operating Systems

Real-time Operating Systems

Distributed Operating Systems