Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides ›...

34
Introduction & History Ch1 · · 1

Transcript of Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides ›...

Page 1: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Introduction & HistoryCh1

CS 422 · T W Bennet · Mississippi College 1

Page 2: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Two Roles of an Operating System

Extended Machineor virtual machine

Device drivers, Processes, File systems, Networking protocols.

Resource ManagerAllocates and enforces

Memory, Disk space, Devices (e.g. printer)

CS 422 · T W Bennet · Mississippi College 2

Page 3: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Structure

Hardware

SoftwareUser mode

Kernel mode Operating system

Web browser

E-mail reader

Music player

User interface program

CS 422 · T W Bennet · Mississippi College 3

Page 4: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

History

First Gen 1940’s and 1950’s

Relays or vacuum tube hardware.Plug board or punch card input.

Programmer runs his own program.

Reserves time on a paper sign-up sheet.

No Operating System

CS 422 · T W Bennet · Mississippi College 4

Page 5: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

History

Problems

• Scheduling inefficiency.

• Time wasted mounting tapes and cards.

Result: Low utilization of a very expensive piece of equipment.

CS 422 · T W Bennet · Mississippi College 5

Page 6: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

History

Second Gen: Batch Mainframes

Mid-1950’s to Mid-1960’s

Transistorized equipment.Punch-card input.

Users distinct from the designers and builders.

Equipment isolated and controlled by operators.

User inputs a stream of jobs, usually on cards.

CS 422 · T W Bennet · Mississippi College 6

Page 7: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

History

Batch Systems

1401 7094 1401

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

Card reader

Tape drive Input

tapeOutput tape

System tape

Printer

CS 422 · T W Bennet · Mississippi College 7

Page 8: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

History

Third Gen: Multiprocessing

Integrated CircuitsMultiprogramming

Leader: IBM 360.

One machine for both scientific and business DP.

Multiprogramming: Leverage the mix of I/Oand compute-bound jobs.Multiple jobs in memory.

Each has its own contiguous region.

Spooling: Main machine does its own job input.

CS 422 · T W Bennet · Mississippi College 8

Page 9: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

History

Time-sharing

Desire to return to interactive use.

Leader: Compatible Time Sharing System (CTSS)

MULTICS: A centralized “computing utility.”Advanced the field

Not a commercial success

Unix: Created by ATT scientists left w/o MULTICSWritten on spare minicomputer

Very popular in academia and elsewhere

BSD and SysV

LinuxCS 422 · T W Bennet · Mississippi College 9

Page 10: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

History

Fourth Gen: Personal Computers

1975: Intel 8080CP/M

1981: IBM PCDOS

1960’s: Douglas Englebert at SRIXerox PARC

GUI

Steve Jobs (Apple) visited PARCLisa

Macintosh

CS 422 · T W Bennet · Mississippi College 10

Page 11: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

History

Fourth Gen: Personal Computers

MS influenced by MacWindows Windows 95 Windows 98 Windows ME

Windows NT Windows 2000 Windows XPVista Windows 7

Unix popular on engineering stationsLinux occasionally

X-Windows

CS 422 · T W Bennet · Mississippi College 11

Page 12: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

OS Types

Mainframe Server Multiprocessor PC

Handheld Embedded

Sensor Node Smart-Card

Real-TimeHard Soft

CS 422 · T W Bennet · Mississippi College 12

Page 13: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Hardware Overview

Hardware Components

CPU MemoryProcess abstraction

I/O DevicesDrivers, clean interfaces

Storage DevicesFile system abstraction

CS 422 · T W Bennet · Mississippi College 13

Page 14: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Hardware Overview

CPUs

Traditionally, there is one CPU.

Multiple-CPUs used on high-end systems.

Muliti-core systems are now the usual.

Multithreading (or hyperthreading) makes it faster for the OSto change which program is running.

CS 422 · T W Bennet · Mississippi College 14

Page 15: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Hardware Overview

CPU Registers

Program counter.

Stack pointer.

General purpose registers.

Program Status Word (PSW)Collection of status values and flags.

Collectively the CPU state

CS 422 · T W Bennet · Mississippi College 15

Page 16: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Hardware Overview

I/O

I/O operations are slow.CPU must start the operation then wait for completion

PollingLoop on a status query

Are we there yet?

Interrupt-DrivenCPU start operation; device interrupts CPU on completion.

Direct Memory Access (DMA)A DMA controller batches of I/O operations.

CS 422 · T W Bennet · Mississippi College 16

Page 17: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Hardware Overview

Interrupts

Much like an asynchronous function call.Similar to event handlers in a GUI.

Peripheral device signals the CPU.

CPU calls the interrupt vector in response.

CPU saves its state, runs the vector, then restores the state.Restoring the PC returns to calling point.

Avoids the need to poll.

CS 422 · T W Bennet · Mississippi College 17

Page 18: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Hardware Overview

Traps

CPU interrupts itself.

Program errors or exceptions.

Divide by zero

Illegal address

Undefined op code

etc

CS 422 · T W Bennet · Mississippi College 18

Page 19: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

O/S-Essential Hardware

Hardware Support for the OS

Certain hardware features are required toimplement a reasonable OS

Traps and Interrupts

CPU Modes

Memory Protection

Clock Interrupt

CS 422 · T W Bennet · Mississippi College 19

Page 20: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

O/S-Essential Hardware

Traps and Interrupts

Interrupt vectors are part of the O/S.Interrupts give control to the O/S.

O/S regains control when I/O completes.

O/S Can let other other code run during I/O

CS 422 · T W Bennet · Mississippi College 20

Page 21: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

O/S-Essential Hardware

CPU Modes

User and supervisory mode.

User code uses user modeOS uses supervisory mode

Some instructions forbidden in user mode.

Interrupts and syscall change to supervisory.

OS switches to user before return.

Reserves certain operations for the OS alone.

CS 422 · T W Bennet · Mississippi College 21

Page 22: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

O/S-Essential Hardware

I/O Operations are Privileged

Most I/O operations are forbidden in user mode.

Gives O/S exclusive control over disk operations.

A user programs must ask the OS to perform IO for it.

Keeps user code from violating file permissions.

CS 422 · T W Bennet · Mississippi College 22

Page 23: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

O/S-Essential Hardware

Memory Protection

In user mode, CPU may access only a portion of the memory.Violations trap

Base and limit registers.Segment codes.

Virtual memory (ch. 3).

Instructions to set or modify protection are privileged.

OS sets memory limits, hardware enforces.

CS 422 · T W Bennet · Mississippi College 23

Page 24: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

O/S-Essential Hardware

Clock Interrupt

Periodically interrupts the CPU.

Setting the interrupt time is privileged.

Makes certain the CPU always gets control eventually.

Allows O/S to enforce CPU allocation.

CS 422 · T W Bennet · Mississippi College 24

Page 25: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

System Calls

How user software talks to the OS.

Syscall instruction is a deliberate trap.

Store arguments in a standard place.Push on the stack or store in standard registers

Execute the syscall instruction.

OS handles the operation and returns.

CS 422 · T W Bennet · Mississippi College 25

Page 26: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Operations Performed With System Calls

Create a file or directory.

Read or write a file.

Send or receive a network packet.

Create or terminate a process.

Anything that requires privileged instructions.

CS 422 · T W Bennet · Mississippi College 26

Page 27: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Structure

MonolithicSingle supervisory-mode kernel provides all O/S services.

LayeredKernel is build in layers each provided additional

services to those above.

Micro-kernelMinimal supervisory-mode kernel

CS 422 · T W Bennet · Mississippi College 27

Page 28: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Linux Layered Kernel

System calls

Interrupts Dispatcher

Virtual file system

Terminals Sockets File systems

Network protocols

Network device drivers

Block device drivers

Character device drivers

I/O scheduler

Generic block layer

Line

di

scip

line

Page cache

Paging page

replacement

Virtual memory

Signal handling

Process/thread creation & termination

CPU scheduling

I/O componentMemory mgt component

Process mgt component

CS 422 · T W Bennet · Mississippi College 28

Page 29: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Micro-kernels

User mode

Microkernel handles interrupts, processes, scheduling, IPC

SysClock

FS Proc. Reinc. Other... Servers

Disk TTY Netw Print Other...

Drivers

Shell Make...

Process

User progs.Other

CS 422 · T W Bennet · Mississippi College 29

Page 30: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Micro-kernels

Clean, extensible design.

Message-passing easily distributed.

Has not been commercially successful for performance reasons.

CS 422 · T W Bennet · Mississippi College 30

Page 31: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Virtual Machines

VM layer divides the resources to provideexact, shrunken copies of the hardware

I/O instructions here

Trap here

Trap here

System calls here

Virtual 370s

CMS CMS CMS

VM/370

370 Bare hardware

DOS mode under Windows

CS 422 · T W Bennet · Mississippi College 31

Page 32: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Two Types

Type 1: VM runs on the hardware.Used by IBM in the 70s.

Type 2: VM runs on an OSVMWare, Virtual Box, Virtual PC

Type 1 hypervisor Host operating system

(a) (b)

...LinuxWindows

Excel Word Mplayer Apollon

Type 2 hypervisor

Guest OS

Guest

Host OS process

OS process

CS 422 · T W Bennet · Mississippi College 32

Page 33: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

IBM Had It Easier

VM must run in user mode and simulateprivileged instructions.

Easiest of the instructions cause traps.

Pentium class machines tend to ignore privileged instructions.Pentium VMs have to do more simulation.

Current generations translate binary by block.

CS 422 · T W Bennet · Mississippi College 33

Page 34: Introduction & History Ch1 - Mississippi Collegesandbox.mc.edu › ~bennet › cs422 › slides › ch1.pdf · Introduction & History Ch1 CSc 422 · T W Bennet · Mississippi Colge

Sources

Tanenbaum, Modern Operating Systems(Course textbook.)

CS 422 · T W Bennet · Mississippi College 34