40
신신신신신 신신신신신신 - 신신신신 1 Lecture Lecture #1 #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

신라대학교 컴퓨터공학과 - 운영체제

1

Lecture #1Lecture #1

Computer System Computer System

OverviewOverview

Page 2: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

2

강의 개요강의 개요

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

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

Page 3: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

3

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

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

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

응용 프로그램 (Application Program)

cf) 미들웨어 (Middleware)

Page 4: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

4

EndUser

Programmer

Operating-System

Designer

Computer Hardware

Operating-System

Utilities

ApplicationPrograms

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

Middleware

Page 5: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

5

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

Page 6: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

6

Components of a simple personal computer

Monitor

Bus

Page 7: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

7

CPU System Bus

MemoryController

Main Memory

I/O Controller I/O Controller

Hard Disk

Printer

Computer Hardware Architecture

Page 8: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

8

Á¦¾îÀåÄ¡

¿¬»êÀåÄ¡

·¹Áö½ºÅÍ

·¹Áö½ºÅÍ

·¹Áö½ºÅÍ

중앙처리장치(CPU)

0000

0001

0002

0003

0004

0005

FFFD

FFFE

FFFF

주기억장치(Main Memory)

보조기억장치(Secondary

Memory)

Program Data

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

Page 9: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

9

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

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

Page 10: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

10

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

Page 11: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

11

User-Visible RegistersUser-Visible Registers

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

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

위한 정보를 저장

Page 12: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

12

The Basic Instruction CycleThe Basic Instruction Cycle

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

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

Page 13: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

13

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

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

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

Module 을 준비한다 (4)

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

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

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

Page 14: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

14

InterruptsInterrupts

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

CPU 은 Interrupt Handler Routine (normally

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

Interrupt Processing Routine / Interrupt Vector

Table

Page 15: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

15

Instruction Cycle with Interrupts!Instruction Cycle with Interrupts!

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

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

중단하고 interrupt handle 를 실행한다

Page 16: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

16

Interrupt Handler Interrupt Handler

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

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

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

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

Page 17: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

17

Simple Interrupt ProcessingSimple Interrupt Processing

Page 18: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

18

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 를 서비스한다

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

Page 19: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

19

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)

Page 20: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

20

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

Page 21: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

21

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

Page 22: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

22

MultiprogrammingMultiprogramming

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

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

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

Page 23: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

23

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

(a) A three-stage pipeline

(b) A superscalar CPU

Page 24: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

24

CPU ModeCPU Mode

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

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

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

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

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

Page 25: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

25

Memory Hierarchy (1)Memory Hierarchy (1)

Registers

Main Memory

Magnetic Disk(Secondary Memory)

Magnetic Tape Optical Disk

Cost per bit,

Frequency of access

Capacity,

Access time

(Tertiary Memory)

Page 26: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

26

Memory Hierarchy (2)Memory Hierarchy (2)

Registers

Cache

Main Memory

Disk Cache

Magnetic Disk

Magnetic Tape Optical Disk

Cost per bit,

Frequency of access

Capacity,

Access time

Page 27: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

27

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

Page 28: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

28

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

Page 29: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

29

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

Page 30: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

30

Hard Disk Driver Hard Disk Driver 구조구조

Structure of a disk drive

Page 31: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

31

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

Page 32: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

32

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 기능을 제공하기 위해서는

필수적으로 요구

Page 33: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

33

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

One base-limit pair and two base-limit pairs

Page 34: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

34

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

Page 35: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

35

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

Page 36: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

36

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)

Page 37: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

37

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

Page 38: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

38

Interrupt-Driven I/OInterrupt-Driven I/O

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

(a) (b)

Page 39: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

39

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

Page 40: Lecture #1

신라대학교 컴퓨터공학과 - 운영체제

40

System BusSystem Bus

Structure of a large Pentium system