01 introduction to computer systems and os.ppt [호환...

33
Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr Real-Time Computing and Communications Lab., Hanyang University http://rtcc.hanyang.ac.kr Introduction to Computer Systems and Operating Systems Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University [email protected]

Upload: tranliem

Post on 21-Aug-2019

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Introduction to Computer Systems and Operating Systems

Minsoo Ryu

Real-Time Computing and Communications Lab.Hanyang University

[email protected]

Page 2: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

2Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 2Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Topics Covered

1. Computer History 2. Computer System Architecture3. Operating System Concepts

Page 3: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

3Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 3Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

What is the First Computer ?

From B.C 4000 Input/Output

• Physical movements by hands and read by eyes• No programming and no special I/O devices

Very volatile memory and slow

Abacus !

The first hand-held computer ?

Page 4: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

4Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 4Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

The ENIAC (1946)

The first computer that uses electricity Technology

• Vacuum tubes Floor space

• 1,000 square feet Weight

• 30 tons Input/Output

• Cards, lights, switches• Human operators

Speed• Less than 5,000 operations per second

Page 5: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

5Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 5Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Mainframe Computers (1)

From 1960s to 1970s Technology

• Transistors Input devices

• Panel switches, paper tape, punched cards

• Card readers, magnetic tape Output devices

• Display lights on the console• Line printers

Page 6: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

6Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 6Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Mainframe Computers (2)

Cost vs. performance Computers were very expensive

• $750,000 plus $185,000 for a high speed printer

Humans were cheap• Significant amount of setup time

Human programmer/operator Program, setup, monitor, and debug Significant amount of setup time

Page 7: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

7Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 7Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Mainframe Computers (3)

Simple Batch Systems To reduce setup time By batching similar jobs

Automatic job sequencing Automatically transfers control

from one job to another. Resident monitor

Instead of human operator When a job completes, it

transfers the control back to the monitor

ResidentMonitor

Page 8: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

8Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 8Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Mainframe Computers (3)Multiprogrammed Batch Systems

Several jobs are kept in main memory at the same time

CPU is multiplexed among them Eventually a job may have to wait

for some task such as I/O operation CPU is switched to another job

Benefit Increase of CPU utilization Reduction of CPU idle time

Job scheduling is required When multiple programs are ready

Page 9: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

9Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 9Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Mainframe Computers (4)

Emergence of faster I/O devices Slow mechanical devices

• Card reader -> CPU -> line printer• CPU works in the microsecond range• Card reader could read 1200 cards per minute

Fast magnetic devices• Card reader -> tape drives -> CPU -> tape drives -> line printer• Performance is limited only by the much faster magnetic units

Page 10: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

10Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 10Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Mainframe Computers (5)

Performance improvement by Spooling Simultaneous Peripheral Operation On-Line Tapes: sequential-access devices Disk systems: random-access devices Spooling overlaps the I/O of one job with the computation of

other jobs• Card reader cannot write onto one end of the tape while the CPU

read from the other• The entire tape had to be written before it was rewound and read• Disk can be used as a very large buffer• Overlapped CPU and I/O operations

Page 11: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

11Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 11Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Modern Computers

Since 1970s With the advent of microprocessor chips Workstations and personal computers

Page 12: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

12Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 12Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Advent of Operating System Concepts

Eliminated the need for human operator Separation of programming from operating

Modern OS features Multi-programming and multi-tasking

• Several programs are kept in main memory• They run at the same time (time-sharing)

Interactive and on-line system• User enters a command and the system executes them• The system seeks the next “control statement” from the user’s

keyboard or mouse Multi-user environment

• Different users can use the computer at the same time

Page 13: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

13Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 13Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Migration of Operating-System Concepts and Features

Page 14: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

14Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 14Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Several Names of Operating System

Resource allocator Manages and allocates resources

Control program Controls the execution of user programs and operations of

I/O devices Kernel

The one program running at all times All else being application programs

Page 15: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

15Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 15Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Topics Covered

1. Computer History2. Computer System Architecture3. Operating System Concepts

Page 16: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

16Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 16Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Computer System Architecture

CPU controls everything in the computer system

Page 17: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

17Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 17Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

How To Control the CPU ?

We can tell the CPU through machine language CPU can understand and execute only instructions

An instruction is a command given to a processor Each instruction is a sequence of 0s and 1s Physical operations such as load, store, add, sub, mul, …

“Programming” means Constructing a sequence of instructions The result is called “program”

Page 18: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

18Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 18Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

von Neumann Architecture

von Neumann machine has A CPU including registers, RAM (random access memory), …

von Neumann machine works by Fetching instructions from memory Executing them on registers

ArithmeticLogic Unit

Registers

ControlUnit

MemoryCPU

0001 load0002 store0003 add

……. 0997 mul0998 sub0999 load

I/O devices

screen disk …

Page 19: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

19Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 19Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Machine Programming

Programming using assembly language One-to-one with instructions

Assembly programming is difficult and tedious Use higher level languages

• C, C++, Java Compilation

• High-level language Assembly code Machine instructions

Load R1 1000Load R2 1004Add R3 R1 R2Store 1008 R3

Reg[R1] Mem[1000]Reg[R2] Mem[1004]Reg[R3] Reg[R1] + Reg[R2]Mem[1008] Reg[R3]

Page 20: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

20Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 20Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

I/O Device Controller

Each I/O device has a controller (or interface) CPU communicates with the I/O controller

Control register: write commands Status register: read the device’s internal state Input register: fetch data Output register: write data

CPU Device’sI/O Controller

Control Registers

Status Registers

Input Registers

Output RegistersI/O instructions

in, out, ins, outs

Page 21: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

21Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 21Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

CPU Execution and I/O

The two main jobs of a computer CPU execution Input/Output

Usually, the main job is I/O The CPU execution is incidental

Page 22: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

22Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 22Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Topics Covered

1. Computer History2. Computer System Architecture3. Operating System Concepts

Page 23: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

23Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 23Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

What is an Operating System?

A program that acts as an intermediary between a user of a computer and the computer hardware

Operating system goals: Execute user programs and make solving user problems

easier Make the computer system convenient to use

Use the computer hardware in an efficient manner

Page 24: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

24Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 24Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Another Definition of Operating System

An operating system is an virtual machine that is easier to program than the raw hardware

Page 25: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

25Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 25Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

What Do Operating Systems Do ?

Hardware abstraction Provide clean, uniform, and standard abstraction

Illusion Make hardware limitations go away

Protection Make CPU, Memory, I/O, and user programs secure

Coordination and Optimization Allow things to work together efficiently

Page 26: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

26Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 26Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Hardware Abstraction

Abstraction ? Picking out key features to reduce complexity Something should be lifted out and preserved Something should be left behind and erased

Hardware abstraction Provide clean, uniform, and standard abstraction hiding

hardware complexity from users

Application Program

Operating System

Hardware

Virtual Machine Interface

Physical Machine Interface

Page 27: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

27Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 27Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Illusion

Make hardware limitations go away As if there are infinite number of processors (time sharing) As if there is extremely large memory (virtual memory)

Every process things it is “the one” As if it has been provided dedicated resources

Operating System

Hardware

Proc 1 Proc 2 Proc 3 ...... Proc n

Page 28: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

28Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 28Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

I/O Protection

Must ensure that users cannot issue I/O instructions They must do it through the operating system

Must ensure that a user program could never gain control of the computer in kernel mode i.e.,) a user program that, as part of its execution, stores a

new address in the interrupt vector

Page 29: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

29Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 29Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Memory Protection

Memory protection kernel from user programs User programs from one another At least for the interrupt vector and the interrupt service

routines Separation of each program’s memory space

Determine the range of legal addresses Base register – holds the smallest legal memory address. Limit register – contains the size of the range Memory outside the defined range is protected

Page 30: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

30Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 30Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Use of A Base and Limit Register

Page 31: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

31Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 31Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Hardware Address Protection

Page 32: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

32Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 32Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

CPU Protection

Must prevent a user program from getting stuck in an infinite loop and never returning the

control to the operating system

Timer – interrupts computer after specified period to ensure operating system maintains control. Timer is decremented every clock tick When timer reaches the value 0, an interrupt occurs Timer commonly used to implement time sharing

Page 33: 01 Introduction to Computer Systems and OS.ppt [호환 모드]rtcc.hanyang.ac.kr/.../01_Introduction_to_Computer_Systems_and_OS.pdf · Real-Time Computing and Communications Lab.,

33Real-Time Computing and Communications Lab., Hanyang University

http://rtcc.hanyang.ac.kr 33Real-Time Computing and Communications Lab., Hanyang Universityhttp://rtcc.hanyang.ac.kr

Coordination and Optimization

Make many things work together efficiently

Concurrency Overlapped I/O and Processing

• I/O devices and the CPU can execute concurrently

Multitasking and multi-user support Efficiency

Multithreading Effective storage management

• Caching, paging, and swapping Fast interrupt handling