40
Chapter 1: Introduction

Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Embed Size (px)

Citation preview

Page 1: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Chapter 1: Introduction

Page 2: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Chapter 1: Introduction

• What Operating Systems Do

• Computer-System Organization

• Operating-System Structure

• Operating-System functionalities• Process Management• Memory Management• Storage Management• Protection and Security

• Computing Environments

Page 3: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Objectives

• To understand the computer system

organization

• To understand the major operating system

components

Page 4: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

What is an Operating System?(user view)

? ? ?

Page 5: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

What is an Operating System?(user view)

OS

#&*…%$#@

For ease of use

Page 6: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

What is an Operating System?(system view)

CPU

MEM

data output

Page 7: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

What is an Operating System?(system view)

CPU

MEM

data output

prog1

prog2

prog3

prog4 Resource allocator

Control program

Page 8: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Computer-system operation(The OS initialization phase)

ROM

RAM

1

2

3

Page 9: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Computer-System Organization(after booting)

OS

Hardware

applicationsSys. call sign

al

cmd

interrupt

polling

Page 10: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

OS operations

OS

applications

Sys. call retu

rn

cmd

controller

buffer

1

2

34

interrupt

AP1

AP2 AP2

I/O devices and the CPU execute concurrently

Page 11: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Common Functions of Interrupts(interrupt vector table, IVT)

mem

IDTR

IDTR: interrupt descriptor table register

ISR

1. Interrupt transfers control to the interrupt service routine

2. Disable all incoming interrupts (why?)3. Save the CPU status of the interrupted

program

1

2’

2”

Page 12: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Common Functions of Interrupts

OS kernel

Hardware

applicationsSys. call sign

al

cmd

interrupt

Software interrupt

Basically, an operating system is interrupt driven.Dual-Mode operation: kernel mode + user mode

polling

Page 13: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Interrupt Handling

1. Save the CPU status (including the CPU status register, program counter and some other registers)

2. Interrupt handling depends on the type of interrupt– polling– vectored interrupt system– vectored interrupt system + polling

3. Execute the interrupt service routine.

Page 14: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Direct Memory Access Structure(DMA)

bus

Page 15: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Direct Memory Access Structure(DMA)

cache

bus

Page 16: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Two I/O Methods

• After I/O starts, control returns to user program only upon I/O completion.– Synchronous I/O– Cons:???– Pros:???

• After I/O starts, control returns to user program without waiting for I/O completion.– Asynchronous I/O– Cons:???– Pros:???

Page 17: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Two I/O Methods

Synchronous Asynchronous

Page 18: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Storage Hierarchy

• Storage systems organized in hierarchy.– Speed– Cost– Volatility

• Caching – a temporary storage area where frequently accessed data can be stored for rapid access.– Register: main memory– Cache memory: main memory– Main memory: disk

Page 19: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Storage-Device Hierarchy

only large storage media that the CPU can

access directly.

extension of main memory that provides

large nonvolatile storage capacity.

compiler

OS

刪掉

Page 20: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Performance of Various Levels of Storage

Page 21: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Cache(Coherency & consistency)

L1 $

bus

L1 $

a=2 a=3

a=0

a=0 a=0

for (i=0..3) { a=a+1;}

Page 22: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Cache(Coherency & consistency)

L1 $

bus

L1 $

a=2 a=3

a=0

a=0 a=0

for (i=0..3) { a=a+1;}

coherency

cons

iste

ncy

Page 23: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Operating System Structure

• Multiprogramming needed for efficiencyServerWhen CPU has to wait (for I/O for example), OS

switches to another program• Timesharing (multitasking) creates interactive

computingPersonal computer+ programs exhaust their time slice

Page 24: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Multiprogramming

CPU I/O CPUready

CPU I/Oready

time

Page 25: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Time sharing

CPU I/O CPUready

I/Oready

time

CPU

CPU

CPUready

Page 26: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Operating-System Operations

OS

applications

Sys. callcontroller

bufferinterrupt

AP2

Page 27: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Dual-mode operation(system call)

OS

applications

Sys. call

AP2User mode

Kernel mode

Page 28: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Dual-mode operation

OS

applicationsAP2User

mode

Kernel mode

trap

ISRSyscall_handler

Exception:= Trap:= Software interrupt

1. Mode=kernel_modePush PC

2. Save machine status3. Jump_to ISR

CPU

Page 29: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Dual-mode operation

OS

applications

Sys. callcontroller

buffer2

34

interrupt

AP1

AP2User mode

Kernel mode Syscall_handler

cmd1

Page 30: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Dual-mode operation

OS

applicationsAP2User

mode

Kernel mode

trap

ISRSyscall_handler

1. restore machine status2. Mode=user_mode

Pop PC

CPU

AP2

Page 31: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Timer

CPU I/O CPUready

I/Oready

time

CPU

CPU

CPUready

timer

interrupt

Page 32: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

OS Structure

OS

Protec-tion

Process manage-

ment

Memory manage-

ment

Storage manage-

ment

security

fork…

malloc..open & close…

setuid…SELinux

passwd…

Page 33: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Computing Environments(symmetric multiprocessor, SMP)

bus

CPU 1 CPU 2CPU 0

Page 34: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

CPU

Computing Environments(chip multiprocessor, CMP)

L1 $

bus

L1 $

L2 $

Core 1Core 0

Page 35: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

CPU

Computing Environments(simultaneously multithreading, SMT)

bus

L1 $

L2 $

Core

Logical processor 0

Logical processor 1

Page 36: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

CPU

Computing Environments(CMP+SMT)

L1 $

bus

L1 $

L2 $

Core 1Core 0

LP0 LP1 LP0 LP1

Page 37: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Computing Environments(symmetric multiprocessor, SMP)

(UMA)

bus

CPU 1CMP+SMT

CPU 2CMP+SMT

CPU 0CMP+SMT

Page 38: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Computing Environments(symmetric multiprocessor, SMP)

(NUMA)

bus

CPU 1CMP+SMT

CPU 2CMP+SMT

CPU 0CMP+SMT

Page 39: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

Embedded systems & web computing

internet

WEB apps

Page 40: Chapter 1: Introduction. What Operating Systems Do Computer-System Organization Operating-System Structure Operating-System functionalities Process Management

參考資料• Silberschatz, Galvin and Gagne, “Operating

system Principles,” 8th ed• Wikipedia, http://www.wikipedia.org/