45
Lecture #1 Lecture #1 Computer System Computer System Overview Overview

Lecture #1

Embed Size (px)

DESCRIPTION

Lecture #1. Computer System Overview. 강의 개요. 운영체제는 컴퓨터 시스템의 하드웨어를 제어하여 사용자에게 프로그램을 실행할 수 있는 환경을 제공한다 운영체제에 있어 중요한 컴퓨터 하드웨어 측면을 살펴본다. 컴퓨터 시스템의 구성. 컴퓨터 시스템의 계층적 구성 하드웨어( Hardware) 소프트웨어( Software) 시스템 소프트웨어( System Software) 운영체제( Operating System) 유틸리티( Utility) - PowerPoint PPT Presentation

Citation preview

Page 1: Lecture #1

Lecture #1Lecture #1

Computer System Computer System

OverviewOverview

Page 2: Lecture #1

강의 개요강의 개요

운영체제는 컴퓨터 시스템의 하드웨어를 제어하여 사용자에게 프로그램을 실행할 수 있는 환경을 제공한다

운영체제에 있어 중요한 컴퓨터 하드웨어 측면을 살펴본다

Operating System 2

Page 3: Lecture #1

컴퓨터 시스템의 구성컴퓨터 시스템의 구성

컴퓨터 시스템의 계층적 구성 하드웨어 (Hardware) 소프트웨어 (Software)

시스템 소프트웨어 (System Software)• 운영체제 (Operating System)• 유틸리티 (Utility)

응용 프로그램 (Application Program)

cf) 미들웨어 (Middleware)

Operating System 3

Page 4: Lecture #1

컴퓨터 시스템의 계층적 구조Operating System 4

EndUser

Programmer

Operating-System

Designer

Computer Hardware

Operating-System

Utilities

ApplicationPrograms

Middleware

Page 5: Lecture #1

Basic Hardware ComponentsBasic Hardware Components

Processor (CPU) Main Memory

현재 실행중인 프로그램과 데이터를 저장 I/O modules (I/O controllers, I/O processors...)

주변 장치와 CPU 사이에 데이터를 전송하는 하드웨어 secondary memory devices (e.g: hard disks) keyboard, display... communications equipment

System interconnection (e.g: Buses) communication among processors, memory,

and I/O modules

Operating System 5

Page 6: Lecture #1

Components of a simple personal computer

Operating System 6

Monitor

Bus

Page 7: Lecture #1

Operating System 7

CPU System Bus

MemoryController

Main Memory

I/O Controller I/O Controller

Hard Disk

Printer

Computer Hardware Architecture

Page 8: Lecture #1

Operating System 8

Á¦¾îÀåÄ¡

¿¬»êÀåÄ¡

·¹Áö½ºÅÍ

·¹Áö½ºÅÍ

·¹Áö½ºÅÍ

중앙처리장치(CPU)

0000

0001

0002

0003

0004

0005

FFFD

FFFE

FFFF

주기억장치(Main Memory)

보조기억장치(Secondary

Memory)

Program Data

CPUCPU 와 주기억장치와 주기억장치

Page 9: Lecture #1

CPU Registers CPU Registers (fast memory on cpu)(fast memory on cpu)

Control & Status Registers Generally not available to user programs some used by CPU to control its operation some used by OS to control program execution

User-Visible Registers available to system (OS) and user programs holds data, addresses, and some condition codes

현재 실행중인 프로그램의 모든 상태 정보를 저장한다

Operating System 9

Page 10: Lecture #1

Examples of Control & Status RegistersExamples of Control & Status Registers

Program Counter (PC) 다음에 수행한 명령어의 주소를 저장

Instruction Register (IR) 지금 수행중인 명령어를 저장

Program Status Word (PSW) 다음의 내용을 포함하는 레지스터 그룹 :

condition codes and status info bits Interrupt enable/disable bit Supervisor(OS)/user mode bit

Operating System 10

Page 11: Lecture #1

User-Visible RegistersUser-Visible Registers

Data Registers 연산하기 위한 데이터나 중간 계산 결과를 저장하는 레지스터

Address Registers 데이터와 명령어의 메모리 주소를 저장 인덱스 또는 오프셋 주소 등과 같이 절대 주소를 계산하기

위한 정보를 저장

Operating System 11

Page 12: Lecture #1

The Basic Instruction CycleThe Basic Instruction Cycle

CPU 는 다음에 수행한 명령어와 데이터를 가져온다 (Fetch Cycle) CPU 는 가져온 명령어를 수행한다 (Execution Cycle) Program counter (PC) 는 다음에 수행할 명령어의 주소를

저장하고 있다 PC 레지스터 값은 fetch cycle 에서 자동적으로 증가한다

Operating System 12

Page 13: Lecture #1

Instruction RegisterInstruction Register

Fetched instruction is placed in the instruction register

Categories Processor-memory

Transfer data between processor and memory Processor-I/O

Data transferred to or from a peripheral device Data processing

Arithmetic or logic operation on data Control

Alter sequence of execution

13Operating System

Page 14: Lecture #1

14

Characteristics of a Hypothetical Characteristics of a Hypothetical MachineMachine

Operating System

Page 15: Lecture #1

15

Example of Program ExecutionExample of Program Execution

Operating System

Page 16: Lecture #1

CPU must wait for I/O to complete!CPU must wait for I/O to complete!

Operating System 16

WRITE 명령어에 의해 제어권이 I/O 프로그램으로 넘어간다

I/O 프로그램은 입출력을 위해 I/O

Module 을 준비한다 (4)

CPU 는 I/O 명령이 수행 완료될 때까지 기다린다 (Idle Wait)

I/O 프로그램은 I/O 명령의 수행 결과를 알려준다

CPU 는 중단된 사용자 프로그램을 수행한다

Page 17: Lecture #1

InterruptsInterrupts

I/O modules 은 event( 입출력 동작의 완료 여부 등 ) 를 INTERRUPT 을 통하여 CPU 에 알린다

CPU 은 Interrupt Handler Routine (normally

part of the OS) 을 실행하여 Interrupt 를 서비스한다

Interrupt Processing Routine / Interrupt Vector

Table

Operating System 17

Page 18: Lecture #1

Instruction Cycle with Interrupts!Instruction Cycle with Interrupts!

CPU 는 현재 실행중인 명령어를 완료하고 interrupt 를 검사한다 만약 pending 된 interrupts 가 없으면 , 현재 프로그램의 다음

명령어를 실행한다 Pending 된 interrupt 가 있으면 , 현재의 프로그램 실행을

중단하고 interrupt handle 를 실행한다

Operating System 18

Page 19: Lecture #1

Interrupt Handler (1)Interrupt Handler (1)

Interrupt 의 특성을 결정하고 필요한 처리 동작을 수행하는 프로그램

Interrupt 가 발생하면 소프트웨어 방식 또는 하드웨어 방식으로 현재 수행중인 프로그램은 중단되고 interrupt handler 가 실행된다

Interrupt handler 수행이 완료되면 중단된 프로그램을 수행한다 (resume)

따라서 , interrupt handler 를 수행하기 전에 현재 수행중인 프로그램의 상태 정보를 저장하여야 한다(content of PC + PSW + registers + ...)

Operating System 19

Page 20: Lecture #1

20

Interrupt Handler (2)Interrupt Handler (2)

Interrupts suspend the normal sequence of execution

Operating System

Page 21: Lecture #1

Simple Interrupt ProcessingSimple Interrupt Processing

Operating System 21

Page 22: Lecture #1

Interrupts improve CPU usageInterrupts improve CPU usage

I/O 프로그램은 I/O Module 을 준비하고 I/O 명령을 전송한 후에 사용자 프로그램으로 되돌아 온다

사용자 프로그램은 I/O 동작이 일어나는 동안 실행을 계속한다 (e.g: printing)- no waiting

I/O 동작이 종료되면 사용자 프로그램은 인터럽트되며 , interrupt handler 가 실행되어 interrupt 를 서비스한다

사용자 프로그램 실행을 재개한다

Operating System 22

Page 23: Lecture #1

Classes of InterruptsClasses of Interrupts

I/O signals normal completion of operation or error

Program Exception overflows try to execute illegal instruction reference outside user’s memory space

Timer preempts a program to perform another task

Hardware failure (e.g: memory parity error)

Operating System 23

Page 24: Lecture #1

Multiple interrupts: sequential orderMultiple interrupts: sequential order

Disable interrupts during an interrupt Interrupts remain pending until the processor enables

interrupts After interrupt handler routine completes, the processor

checks for additional interrupts

Operating System 24

Page 25: Lecture #1

Multiple Interrupts: prioritiesMultiple Interrupts: priorities

Higher priority interrupts cause lower-priority interrupts to wait

Causes a lower-priority interrupt handler to be interrupted Example: when input arrives from communication line, it

needs to be absorbed quickly to make room for more input

Operating System 25

Page 26: Lecture #1

MultiprogrammingMultiprogramming

프로그램은 I/O 장치를 통하여 입출력하는 동안 I/O 동작이 완료될 때까지 기다려야 한다

하나의 프로그램이 입출력을 기다리는 동안 CPU 는 다른 프로그램을 실행할 수 있다

Interrupts are mostly effective when a single CPU is shared among several concurrently active processes

Operating System 26

Page 27: Lecture #1

향상된 향상된 CPU CPU 내부 구조내부 구조

(a) A three-stage pipeline

(b) A superscalar CPU

Operating System 27

Page 28: Lecture #1

CPU ModeCPU Mode

CPU 동작 모드 커널 모드 (Kernel Mode or Supervisor Mode)

CPU 의 모든 명령어를 실행할 수 있음 하드웨어의 각 특성을 이용할 수 있음 운영체제는 하드웨어를 완벽하게 접근할 수 있도록 커널

모드에서 동작 사용자 모드 (User Mode)

CPU 의 일부 명령어만을 실행할 수 있음 하드웨어의 일부 특성 만을 접근할 수 있음 사용자 프로그램은 사용자 모드에서 실행

PSW 의 모드 비트 설정에 의해 CPU 모드 전환 Trap 등의 명령어에 의해 PSW 의 모드 비트를 수정

Operating System 28

Page 29: Lecture #1

Memory Hierarchy (1)Memory Hierarchy (1)

Operating System 29

Registers

Main Memory

Magnetic Disk(Secondary Memory)

Magnetic Tape Optical Disk

Cost per bit,

Frequency of access

Capacity,

Access time

(Tertiary Memory)

Page 30: Lecture #1

Memory Hierarchy (2)Memory Hierarchy (2)

Operating System 30

Registers

Cache

Main Memory

Disk Cache

Magnetic Disk

Magnetic Tape Optical Disk

Cost per bit,

Frequency of access

Capacity,

Access time

Page 31: Lecture #1

31

Memory Hierarchy (3)Memory Hierarchy (3)

Operating System

Page 32: Lecture #1

Cache MemoryCache Memory

Small cache of expensive but very fast memory interacting with slower but much larger memory

Invisible to OS and user programs but interact with other memory management hardware

Processor first checks if word referenced to is in cache

If not found in cache, a block of memory containing the word is moved to the cache

Operating System 32

Page 33: Lecture #1

The Hit RatioThe Hit Ratio

Hit ratio = fraction of access where data is in cache

T1 = access time for fast memory

T2 = access time for slow memory

T2 >> T1 When hit ratio is close to 1

the average access time is close to T1

Operating System 33

Page 34: Lecture #1

Locality of ReferenceLocality of Reference

Memory reference for both instruction and data tend to cluster over a long period of time

Example: once a loop is entered, there is frequent access to a small set of instructions

Hence: once a word gets referenced, it is likely that nearby words will get referenced often in the near future

Thus, the hit ratio will be close to 1 even for a small cache

Operating System 34

Page 35: Lecture #1

Hard Disk Driver Hard Disk Driver 구조구조

Structure of a disk drive

Operating System 35

Page 36: Lecture #1

Disk CacheDisk Cache

A portion of main memory used as a buffer to temporarily to hold data for the disk

Locality of reference also applies here: once a record gets referenced, it is likely that nearby records will get referenced often in the near future

If a record referenced is not in the disk cache, the sector containing the record is moved into the disk cache

Read-ahead policy

Operating System 36

Page 37: Lecture #1

MMU(Memory Management Unit) (1)MMU(Memory Management Unit) (1)

Multiprogramming 환경에서 메모리에 두 개 이상의 프로그램을 유지하기 위해서는 다음의 두 가지 문제점에 대한 선결을 요구1. 프로그램간 , 그리고 커널과 프로그램간의 보호2. 메모리 재할당 처리 MMU 를 통하여 해결

MMU(Memory Management Unit) 프로그램 상의 가상 주소 (virtual address) 을 실제 메모리에

매핑하여 사용하는 물리 주소 (physical address) 로 변환하는 장치

대개의 경우 CPU 내부에 구현 Multitasking & virtual memory 기능을 제공하기 위해서는

필수적으로 요구

Operating System 37

Page 38: Lecture #1

MMU(Memory Management Unit) (2)MMU(Memory Management Unit) (2)

One base-limit pair and two base-limit pairsOperating System 38

Page 39: Lecture #1

I/O Module StructureI/O Module Structure

Data to/from system bus are buffered in data register(s) Status/Control register(s) holds

current status information current control information from

I/O logic interacts with CPU via control bus Contains logic specific to the interface of each device

Operating System 39

Page 40: Lecture #1

I/O communication techniquesI/O communication techniques

3 techniques are possible for I/O operation Programmed I/O

Does not use interrupts: CPU has to wait for completion of each I/O operation

Interrupt-driven I/O CPU can execute code during I/O operation: it gets

interrupted when I/O operation is done. Direct Memory Access(DMA)

A block of data is transferred directly from/to memory without going through CPU

Operating System 40

Page 41: Lecture #1

Programmed I/OProgrammed I/O

I/O module performs the action on behalf of the processor

But the I/O module does not interrupt the CPU when I/O is done

Processor is kept busy checking status of I/O module(polling)

Operating System 41

Page 42: Lecture #1

Interrupt-Driven I/OInterrupt-Driven I/O

Processor is interrupted when I/O module ready to exchange data

Processor is free to do other work

No needless waiting

Consumes a lot of processor time because every word read or written passes through the processor

Operating System 42

Page 43: Lecture #1

Interrupt-Driven I/OInterrupt-Driven I/O

(a) Steps in starting an I/O device and getting interrupt(b) How the CPU is interrupted

Operating System 43

(a) (b)

Page 44: Lecture #1

Direct Memory Access(DMA) Direct Memory Access(DMA)

CPU issues request to a DMA module (separate module or incorporated into I/O module)

DMA module transfers a block of data directly to or from memory (without going through CPU)

An interrupt is sent when the task is complete

The CPU is only involved at the beginning and end of the transfer

The CPU is free to perform other tasks during data transfer

Operating System 44

Page 45: Lecture #1

System BusSystem Bus

Structure of a large Pentium systemOperating System 45