chapter 1 introductionweb-ext.u-aizu.ac.jp/~hitoshi/courses/os06/slides/chap1.pdf · limit-2...

34
Chapter 1 Introduction 1.1 What is an operating system 1.2 History of operating systems 1.3 The operating system zoo 1.4 Computer hardware review 1.5 Operating system concepts 1.6 System calls 1.7 Operating system structure

Upload: others

Post on 10-Jun-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Chapter 1

Introduction

1.1 What is an operating system

1.2 History of operating systems

1.3 The operating system zoo

1.4 Computer hardware review

1.5 Operating system concepts

1.6 System calls

1.7 Operating system structure

Page 2: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Introduction

Banking system

Airline reservation

Operating system

Web browser

Compilers Editors

Application programs

Hardware

System programs

Command interpreter

Machine language

Microarchitecture

Physical devices

• A computer system consists of

– hardware

– large system programs

– large application programs

2

Page 3: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

What is an Operating System

• It is an extended machines

– Hides the messy details which must be performed

– Presents user with a virtual machine, easier to use

• It is a resource manager

– Presents user with a virtual machine, easier to use

– Each program gets space on the resource

3

Page 4: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

History of Operating Systems (1)

1401 7094 1401

(a) (b) (c) (d) (e) (f)

Card reader

Tape drive Input

tapeOutput tape

System tape

Printer

• Early batch system

– bring cards to 1401

– read cards to tape

– put tape on 7094 which does computing

– put tape on 1401 which prints output

4

Page 5: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

History of Operating Systems (2)

• First generation 1945 - 1955

– vacuum tubes, plug boards

• Second generation 1955 - 1965

– transistors, batch systems

• Third generation 1965 - 1980

– ICs and multiprogramming

• Fourth generation 1980 - present

– personal computers

5

Page 6: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

History of Operating Systems (3)

$JOB, 10,6610802, MARVIN TANENBAUM

$FORTRAN

$LOAD

$RUN

$END

Fortran program

Data for program

• Structure of a typical FMS job - 2nd generation

6

Page 7: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

History of Operating Systems (4)

Job 3

Job 2

Job 1

Operating system

Memory partitions

• Multiprogramming system

– three jobs in memory - 3rd generation

7

Page 8: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

The Operating System Zoo

• Mainframe operating systems

• Server operating systems

• Multiprocessor operating systems

• Personal computer operating systems

• Real-time operating systems

• Embedded operating systems

• Smart card operating systemstems

8

Page 9: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Computer Hardware Review (1)

Monitor

Keyboard Floppy disk drive

Hard disk drive

Hard disk

controller

Floppy disk

controller

Keyboard controller

Video controllerMemoryCPU

Bus

• Components of a simple personal computer

9

Page 10: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Computer Hardware Review (2)

Fetch unit

Fetch unit

Fetch unit

Decode unit

Decode unit

Execute unit

Execute unit

Execute unit

Execute unit

Decode unit

Holding buffer

(a) (b)

(a) A three-stage pipeline

(b) A superscalar CPU

10

Page 11: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Computer Hardware Review (3)

Registers

Cache

Main memory

Magnetic tape

Magnetic disk

1 nsec

2 nsec

10 nsec

10 msec

100 sec

<1 KB

1 MB

64-512 MB

5-50 GB

20-100 GB

Typical capacityTypical access time

• Typical memory hierarchy

– numbers shown are rough approximations

11

Page 12: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Computer Hardware Review (4)

Surface 2Surface 1

Surface 0

Read/write head (1 per surface)

Direction of arm motion Surface 3

Surface 5

Surface 4

Surface 7

Surface 6

Structure of disk drive

12

Page 13: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Computer Hardware Review (5)

User program and data

User program and data

Operating System

Address

0xFFFFFFFF

Limit

Base

0(a)

User-2 data

User-1 data

User program

Operating System

Base-2

Limit-2

Limit-2

Limit-1

Base-2

Base-1

(b)

Limit-1

Base-1

Registers when program 1 is running

Registers when program 2 is running

One base-limit pair and two base-limit pairs

13

Page 14: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Computer Hardware Review (6)

CPUInterrupt controller

Disk controller

Disk drive

Current instruction

Next instruction

1. Interrupt3. Return

2. Dispatch to handler

Interrupt handler

(b)(a)

1

3

4 2

(a) Steps in starting an I/O device and getting interrupt

(b) How the CPU is interrupted

14

Page 15: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Computer Hardware Review (7)

ISA bridge

Modem

Mouse

PCI bridgeCPU

Main memory

SCSI USB

Local bus

Sound card Printer Available

ISA slot

ISA bus

IDE disk

Available PCI slot

Key- board

Mon- itor

Graphics adaptor

Level 2 cache

Cache bus Memory bus

PCI bus

Structure of a large Pentium system

15

Page 16: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Concepts (1)

A

B

D E F

C

• A process tree

– A created two child processes,B and C

– B created three child processes,D,E,and F

16

Page 17: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Concepts (2)

(a) A potential deadlock

(b) An actual deadlock

17

Page 18: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Concepts (3)

Root directory

Students Faculty

Leo Prof.Brown

Files

Courses

CS101 CS105

Papers Grants

SOSP COST-11

Committees

Prof.Green Prof.WhiteMattyRobbert

File system for a university department

18

Page 19: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Concepts (4)

Root Floppy

a b

c d c d

a bx y

x y

(a) (b)

• Before mounting

– files on floppy are inaccessible

• After mounting floppy on b

– files on floppy are part of file hierarchy

19

Page 20: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Concepts (5)

ProcessPipe

Process

A B

Two processes connected by a pipe

20

Page 21: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Steps in Making a System Call

Return to caller

410

6

0

9

7 8

321

11

DispatchSys call handler

Address 0xFFFFFFFF

User space

Kernel space (Operating system)

Library procedure read

User program calling read

Trap to the kernelPut code for read in register

Increment SPCall readPush fdPush &bufferPush nbytes

5

There are 11 steps in making the system call read (fd,buffer,nbytes)

21

Page 22: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Some System Calls (1)

22

Page 23: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Some System Calls For File Management (2)

23

Page 24: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

System Calls(1)

• A stripped down shell:

#define TRUE 1

while (TRUE) { /* repeat forever */type_prompt( ); /* display prompt on the screen */read_command(command, parameters); /* read input from terminal */

if (fork( ) != 0) { /* fork off child process *//* Parent code. */waitpid(−1, &status, 0); /* wait for child to exit */

} else {/* Child code. */execve(command, parameters, 0); /* execute command */

}}

24

Page 25: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

System Calls(2)

�� �Address (hex)FFFF

0000

Stack

Data

Text

Gap

• Processes have three segments:text, data, stack

25

Page 26: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

System Calls(3)

/usr/ast /usr/jim

16 81 40

mail games test

(a)

31 70 59 38

bin memo f.c. prog1

/usr/ast /usr/jim

16 81 40 70

mail games test note

(b)

31 70 59 38

bin memo f.c. prog1

(a) Two directories before linking/usr/jim/memo to ast’s directory

(b) The same directories after linking

26

Page 27: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

System Calls(4)

(a) (b)

bin dev lib mnt usr bin dev usr lib

(a) File system before the mount

(b) File system after the mount

27

Page 28: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

System Calls(5)

� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������UNIX Win32 Description� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������

fork CreateProcess Create a new process� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������waitpid WaitForSingleObject Can wait for a process to exit� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������execve (none) CreateProcess = fork + execve� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������exit ExitProcess Terminate execution� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������open CreateFile Create a file or open an existing file� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������close CloseHandle Close a file� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������read ReadFile Read data from a file� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������write WriteFile Write data to a file� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������lseek SetFilePointer Move the file pointer� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������stat GetFileAttributesEx Get various file attributes� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������mkdir CreateDirectory Create a new directory� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������rmdir RemoveDirectory Remove an empty directory� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������link (none) Win32 does not support links� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������unlink DeleteFile Destroy an existing file� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������mount (none) Win32 does not support mount� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������umount (none) Win32 does not support mount� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������chdir SetCurrentDirectory Change the current working directory� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������chmod (none) Win32 does not support security (although NT does)� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������kill (none) Win32 does not support signals� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������time GetLocalTime Get the current time� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������

����������������������������

����������������������������

����������������������������

����������������������������

Some Win32 API calls

28

Page 29: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Structure(1)

Main procedure

Service procedures

Utility procedures

Simple structuring model for a monolithic system

29

Page 30: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Structure(2)

� �������������������������������������������������������������������������������������������������Layer Function� �������������������������������������������������������������������������������������������������

5 The operator� �������������������������������������������������������������������������������������������������4 User programs� �������������������������������������������������������������������������������������������������3 Input/output management� �������������������������������������������������������������������������������������������������2 Operator-process communication� �������������������������������������������������������������������������������������������������1 Memory and drum management� �������������������������������������������������������������������������������������������������0 Processor allocation and multiprogramming� �������������������������������������������������������������������������������������������������

����������

����������

����������

Structure of the THE operating system

30

Page 31: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Structure(3)

I/O instructions here

Trap here

Trap here

System calls here

Virtual 370s

CMS CMS CMS

VM/370

370 Bare hardware

Structure of VM/370 with CMS(Conversational Monitor System)

• For time sharing system

• Virtual 370s

– Separation of multiprograming

– Exact copies of 370 HW

• VM/370

– Extended machine

31

Page 32: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Structure(4)

Client process

Client process

Process server

Terminal server

File server

Memory server

Microkernel

User mode

Kernel mode

Client obtains service by sending messages to server processes

The client-server model

• Minimum kernel part

– Verification work smaller

– Destribution (Next slide)

32

Page 33: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Operating System Structure(5)

Machine 1 Machine 2 Machine 3 Machine 4

Client

Kernel

File server

Kernel

Process server

Kernel

Terminal server

Kernel

Message from client to server

Network

The client-server model in a distributed system

33

Page 34: Chapter 1 Introductionweb-ext.u-aizu.ac.jp/~hitoshi/COURSES/OS06/SLIDES/chap1.pdf · Limit-2 Limit-1 Base-2 Base-1 (b) Limit-1 Base-1 Registers when program 1 is running Registers

Metric Units

Exp. Explicit Prefix Exp. Explicit Prefix

10−3 0.001 milli 103 1,000 Kilo

10−6 0.000001 micro 106 1,000,000 Mega

10−9 0.000000001 nano 109 1,000,000,000 Giga

10−12 0.000000000001 pico 1012 1,000,000,000,000 Tera

10−15 0.000000000000001 femto 1015 1,000,000,000,000,000 Peta

10−18 0.000000000000000001 atto 1018 1,000,000,000,000,000,000 Exa

10−21 (omitted) zepto 1021 (omitted) Zetta

10−24 (omitted) yocto 1024 (omitted) Yotta

The metric prefixes

34