CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user...

40
CS 134: Operating Systems Definitions, Abstractions, Taxonomies, Early History 1 / 36 CS 134: Operating Systems Definitions, Abstractions, Taxonomies, Early History 2012-12-06 CS34

Transcript of CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user...

Page 1: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

CS 134:Operating Systems

Definitions, Abstractions, Taxonomies, Early History

1 / 36

CS 134:Operating Systems

Definitions, Abstractions, Taxonomies, Early History

2012

-12-

06

CS34

Page 2: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Overview

What Is an OS?

History

Hardware

2 / 36

Overview

What Is an OS?

History

Hardware

2012

-12-

06

CS34

Overview

Page 3: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

What is an Operating System Anyway?

Class Exercise: Devise three separate definitions. Discuss.

3 / 36

What is an Operating System Anyway?

Class Exercise: Devise three separate definitions. Discuss.

2012

-12-

06

CS34What Is an OS?

What is an Operating System Anyway?

Several slides follow that aren’t onhandout.

Page 4: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s A Programmer’s Toolkit

Provide useful functionality to programs:I Prevent duplicated workI Promote reuse

4 / 36

It’s A Programmer’s Toolkit

Provide useful functionality to programs:I Prevent duplicated workI Promote reuse

2012

-12-

06

CS34What Is an OS?

It’s A Programmer’s Toolkit

Page 5: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Control Program

Provide the rules for the how the machine will operate:I Control the operation of the I/O devicesI Ensure smooth running of the machine

5 / 36

It’s a Control Program

Provide the rules for the how the machine will operate:I Control the operation of the I/O devicesI Ensure smooth running of the machine

2012

-12-

06

CS34What Is an OS?

It’s a Control Program

Page 6: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s an Abstraction Layer

Make the machine “nicer”, easier to program, higher level. . .I Hide some of the idiosyncrasies of the machineI Provide functionality the underlying machine doesn’t have

Hardware

Operating System

Application

User

6 / 36

It’s an Abstraction Layer

Make the machine “nicer”, easier to program, higher level. . .I Hide some of the idiosyncrasies of the machineI Provide functionality the underlying machine doesn’t have

Hardware

Operating System

Application

User

2012

-12-

06

CS34What Is an OS?

It’s an Abstraction Layer

Page 7: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s an Abstraction Layer

Make the machine “nicer”, easier to program, higher level. . .I Hide some of the idiosyncrasies of the machineI Provide functionality the underlying machine doesn’t have

Hardware

Operating System

Application

User

The Core Services and Application Services layers and the Carbon and Cocoa applicationenvironments are packaged in umbrella frameworks (described in the chapter “UmbrellaFrameworks” (page 97)). Many public APIs of the kernel environment are exported throughheaders found in /usr/include.

The first part of this chapter, as summarized in the foregoing paragraphs, presents the architectureof Mac OS X as layers of system software. Following this static perspective of Mac OS X is a moredynamic view that traces the progress of a user event through the system. A typical event in MacOS X originates when the user manipulates an input device such as a mouse or a keyboard. Thedevice driver associated with that device, through the I/O Kit, creates a low-level event, puts itin the window server’s event queue, and notifies the window server. The window serverdispatches the event to the appropriate run-loop port of the target process. There the event ispicked up by the Carbon Event Manager and forwarded to the event-handling mechanismappropriate to the application environment. Events can also be asynchronous, such as a networkpacket containing configuration changes.

A Layered Perspective

A common way to look at complex software is to separate out parts of that software into “layers.”Visually depicted, one layer sits on top of another, with the most fundamental layer on the bottom.This kind of diagram suggests the general interfaces and dependencies between the layers ofsoftware. The higher layers of software, which are the closest to actual application code, dependon the layer immediately under them, and that intermediate layer depends on an even lowerlayer.

Mac OS X is reducible to such a perspective. Figure 3-1 (page 40) illustrates the general structureof Mac OS X system software as interdependent layers of libraries, frameworks, and services.

Figure 3-1 Mac OS X as layers of system software

BSDCarbon Cocoa Java(JDK)

BSDClassic

Core Services

Kernel environment

QuickTimeApplication Services

Applicationenvironment

Although this diagram does help clarify the overall architecture, there are dangers in thenecessarily over-simplified view it presents. The Mac OS X services and subsystems that oneapplication uses—and how it uses them—can be very different from those used by anotherapplication, even one of a similar type. Dependencies and interfaces at the different levels canvary from program to program depending on individual requirements and realities.

With that caveat aside, let’s take a guided tour through the layers depicted in this diagram.

40 A Layered Perspective© Apple Computer, Inc. 2003

C H A P T E R 3

System Architecture

6 / 36

It’s an Abstraction Layer

Make the machine “nicer”, easier to program, higher level. . .I Hide some of the idiosyncrasies of the machineI Provide functionality the underlying machine doesn’t have

Hardware

Operating System

Application

User

The Core Services and Application Services layers and the Carbon and Cocoa applicationenvironments are packaged in umbrella frameworks (described in the chapter “UmbrellaFrameworks” (page 97)). Many public APIs of the kernel environment are exported throughheaders found in /usr/include.

The first part of this chapter, as summarized in the foregoing paragraphs, presents the architectureof Mac OS X as layers of system software. Following this static perspective of Mac OS X is a moredynamic view that traces the progress of a user event through the system. A typical event in MacOS X originates when the user manipulates an input device such as a mouse or a keyboard. Thedevice driver associated with that device, through the I/O Kit, creates a low-level event, puts itin the window server’s event queue, and notifies the window server. The window serverdispatches the event to the appropriate run-loop port of the target process. There the event ispicked up by the Carbon Event Manager and forwarded to the event-handling mechanismappropriate to the application environment. Events can also be asynchronous, such as a networkpacket containing configuration changes.

A Layered Perspective

A common way to look at complex software is to separate out parts of that software into “layers.”Visually depicted, one layer sits on top of another, with the most fundamental layer on the bottom.This kind of diagram suggests the general interfaces and dependencies between the layers ofsoftware. The higher layers of software, which are the closest to actual application code, dependon the layer immediately under them, and that intermediate layer depends on an even lowerlayer.

Mac OS X is reducible to such a perspective. Figure 3-1 (page 40) illustrates the general structureof Mac OS X system software as interdependent layers of libraries, frameworks, and services.

Figure 3-1 Mac OS X as layers of system software

BSDCarbon Cocoa Java(JDK)

BSDClassic

Core Services

Kernel environment

QuickTimeApplication Services

Applicationenvironment

Although this diagram does help clarify the overall architecture, there are dangers in thenecessarily over-simplified view it presents. The Mac OS X services and subsystems that oneapplication uses—and how it uses them—can be very different from those used by anotherapplication, even one of a similar type. Dependencies and interfaces at the different levels canvary from program to program depending on individual requirements and realities.

With that caveat aside, let’s take a guided tour through the layers depicted in this diagram.

40 A Layered Perspective© Apple Computer, Inc. 2003

C H A P T E R 3

System Architecture

2012

-12-

06

CS34What Is an OS?

It’s an Abstraction Layer

Page 8: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Virtual Machine

OS provides an environmentThis environment can be seen as a “new machine”. . .

Hardware —Physical machine+ Core OS —Virtual machine

+ OS Libraries —Virtual machine+ OS Utilities —Virtual machine

+ Application —Virtual machine

7 / 36

It’s a Virtual Machine

OS provides an environmentThis environment can be seen as a “new machine”. . .

Hardware —Physical machine+ Core OS —Virtual machine

+ OS Libraries —Virtual machine+ OS Utilities —Virtual machine

+ Application —Virtual machine

2012

-12-

06

CS34What Is an OS?

It’s a Virtual Machine

Page 9: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Protection Layer

Make the machine more robust—less scope for a bug to havedevastating consequences

I OS does everything programs can’t be trusted to doI OS makes programs play nice with others

8 / 36

It’s a Protection Layer

Make the machine more robust—less scope for a bug to havedevastating consequences

I OS does everything programs can’t be trusted to doI OS makes programs play nice with others

2012

-12-

06

CS34What Is an OS?

It’s a Protection Layer

Page 10: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Policy Enforcer

OS provides the mechanisms to enforce various policies

Class Exercise: Examples?

9 / 36

It’s a Policy Enforcer

OS provides the mechanisms to enforce various policies

Class Exercise: Examples?

2012

-12-

06

CS34What Is an OS?

It’s a Policy Enforcer

Page 11: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Policy Enforcer

OS provides the mechanisms to enforce various policies

Class Exercise: Examples?

9 / 36

It’s a Policy Enforcer

OS provides the mechanisms to enforce various policies

Class Exercise: Examples?

2012

-12-

06

CS34What Is an OS?

It’s a Policy Enforcer

Page 12: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Resource Manager

The operating system manages physical resources:I ProcessorI MemoryI Storage devicesI Network devices

etc. . .

10 / 36

It’s a Resource Manager

The operating system manages physical resources:I ProcessorI MemoryI Storage devicesI Network devices

etc. . .

2012

-12-

06

CS34What Is an OS?

It’s a Resource Manager

Page 13: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Resource Manager (cont’d.)

The operating system manages virtual resources:I ProcessesI FilesI UsersI Network connectionsI Windows

etc.. . .

11 / 36

It’s a Resource Manager (cont’d.)

The operating system manages virtual resources:I ProcessesI FilesI UsersI Network connectionsI Windows

etc.. . .

2012

-12-

06

CS34What Is an OS?

It’s a Resource Manager (cont’d.)

Page 14: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Product

Many operating systems are sold by commercial companiesI Market vs. technical considerationsI The operating system is what comes in the box marked

“operating system”

12 / 36

It’s a Product

Many operating systems are sold by commercial companiesI Market vs. technical considerationsI The operating system is what comes in the box marked

“operating system”

2012

-12-

06

CS34What Is an OS?

It’s a Product

Page 15: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

Fundamental Abstractions

What are the (user-level) abstractions we’d expect to find in amodern OS?

13 / 36

Fundamental Abstractions

What are the (user-level) abstractions we’d expect to find in amodern OS?

2012

-12-

06

CS34What Is an OS?

Fundamental Abstractions

Page 16: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

Fundamental Abstractions

Include. . .

I System callsI Processes

I ThreadsI Address spaces

I FilesI FilesI DirectoriesI Filesystems

I EventsI AsynchronousI Synchronous

I IPC MechanismsI SemaphoresI MutexesI Condition Variables

I Communications channelsI PipelinesI Network connections

I UsersI (Remote) Hosts

14 / 36

Fundamental Abstractions

Include. . .

I System callsI Processes

I ThreadsI Address spaces

I FilesI FilesI DirectoriesI Filesystems

I EventsI AsynchronousI Synchronous

I IPC MechanismsI SemaphoresI MutexesI Condition Variables

I Communications channelsI PipelinesI Network connections

I UsersI (Remote) Hosts

2012

-12-

06

CS34What Is an OS?

Fundamental Abstractions

Page 17: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Resource Manager

What are the “resources” that an operating system manages?

15 / 36

It’s a Resource Manager

What are the “resources” that an operating system manages?

2012

-12-

06

CS34What Is an OS?

It’s a Resource Manager

Page 18: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Resource Manager

The operating system manages physical resources:I ProcessorI MemoryI Storage devicesI Network devices

etc.. . .

16 / 36

It’s a Resource Manager

The operating system manages physical resources:I ProcessorI MemoryI Storage devicesI Network devices

etc.. . .

2012

-12-

06

CS34What Is an OS?

It’s a Resource Manager

Page 19: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

It’s a Resource Manager (cont’d.)

The operating system manages virtual resources:I ProcessesI FilesI UsersI Network connectionsI Windows

etc.. . .

17 / 36

It’s a Resource Manager (cont’d.)

The operating system manages virtual resources:I ProcessesI FilesI UsersI Network connectionsI Windows

etc.. . .

2012

-12-

06

CS34What Is an OS?

It’s a Resource Manager (cont’d.)

Page 20: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

Taxonomy of Computer Systems

Different computer systems ask different things from their OS

Class Exercise: Give some dimensions across which computersystems vary

18 / 36

Taxonomy of Computer Systems

Different computer systems ask different things from their OS

Class Exercise: Give some dimensions across which computersystems vary

2012

-12-

06

CS34What Is an OS?

Taxonomy of Computer Systems

Page 21: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

Taxonomy of Computer Systems

Different computer systems ask different things from their OS

Class Exercise: Give some dimensions across which computersystems vary

18 / 36

Taxonomy of Computer Systems

Different computer systems ask different things from their OS

Class Exercise: Give some dimensions across which computersystems vary

2012

-12-

06

CS34What Is an OS?

Taxonomy of Computer Systems

Page 22: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

What Is an OS?

Partial Taxonomy of Computer Systems

Different computer systems ask different things from their OS:

Special-purpose ↔ General-purposeSingle-user ↔ Multi-user

Non–Resource-sharing ↔ Resource sharingSingle processor ↔ Multiprocessor

Stand alone ↔ NetworkedCentralized ↔ Distributed

Batch ↔ InteractiveDeadline-free ↔ Real-time

Insecure ↔ SecureSymmetric ↔ Asymmetric

Simple ↔ ComplexSmall ↔ Large

Inexpensive ↔ Expensiveetc.

19 / 36

Partial Taxonomy of Computer Systems

Different computer systems ask different things from their OS:

Special-purpose ↔ General-purposeSingle-user ↔ Multi-user

Non–Resource-sharing ↔ Resource sharingSingle processor ↔ Multiprocessor

Stand alone ↔ NetworkedCentralized ↔ Distributed

Batch ↔ InteractiveDeadline-free ↔ Real-time

Insecure ↔ SecureSymmetric ↔ Asymmetric

Simple ↔ ComplexSmall ↔ Large

Inexpensive ↔ Expensiveetc.

2012

-12-

06

CS34What Is an OS?

Partial Taxonomy of Computer Systems

Page 23: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

History

Early Computers

1950s—large complex machinesI Operated directly from a consoleI Used interactively by a single userI Ran one program at a time (uniprogramming)I Read data from paper tape, punched cards, or toggle

switchesOS? Maybe a library containing code to work the I/O devices wasuseful.

20 / 36

Early Computers

1950s—large complex machinesI Operated directly from a consoleI Used interactively by a single userI Ran one program at a time (uniprogramming)I Read data from paper tape, punched cards, or toggle

switchesOS? Maybe a library containing code to work the I/O devices wasuseful.

2012

-12-

06

CS34History

Early Computers

Page 24: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

History

Simple Batch Systems

Provide better use of resources:I Users access computer indirectlyI Programs and input (jobs) taken from a batch queueI Computer has a human operator to feed it jobs

1401 7094 1401

Card reader

Tape drive Input

tapeOutput tape

System tape

Printer

Need to:I Manage the jobs:I Protect the next program from the previous program

21 / 36

Simple Batch Systems

Provide better use of resources:I Users access computer indirectlyI Programs and input (jobs) taken from a batch queueI Computer has a human operator to feed it jobs

1401 7094 1401

Card reader

Tape drive Input

tapeOutput tape

System tape

Printer

Need to:I Manage the jobs:I Protect the next program from the previous program

2012

-12-

06

CS34History

Simple Batch Systems

Page 25: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

History

SPOOLing Batch Systems

Provide better use of resources—buffer input and outputI Read-ahead input from disk/tapeI Write-behind output to disk/tape

Class Exercise: Why does buffering improve performance?Does buffering always improve performance?

(What assumptions are we making?)

22 / 36

SPOOLing Batch Systems

Provide better use of resources—buffer input and outputI Read-ahead input from disk/tapeI Write-behind output to disk/tape

Class Exercise: Why does buffering improve performance?Does buffering always improve performance?

(What assumptions are we making?)

2012

-12-

06

CS34History

SPOOLing Batch Systems

Page 26: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

History

SPOOLing Batch Systems

Provide better use of resources—buffer input and outputI Read-ahead input from disk/tapeI Write-behind output to disk/tape

Class Exercise: Why does buffering improve performance?Does buffering always improve performance?

(What assumptions are we making?)

22 / 36

SPOOLing Batch Systems

Provide better use of resources—buffer input and outputI Read-ahead input from disk/tapeI Write-behind output to disk/tape

Class Exercise: Why does buffering improve performance?Does buffering always improve performance?

(What assumptions are we making?)

2012

-12-

06

CS34History

SPOOLing Batch Systems

Page 27: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

History

Multiprogrammed Batch Systems

Provide better use of resources—multiplex the processor:I Run multiple independent programs at onceI Switch to another program when running program waits for

I/OMore work for OS. More complex management of

I I/OI MemoryI Processor

23 / 36

Multiprogrammed Batch Systems

Provide better use of resources—multiplex the processor:I Run multiple independent programs at onceI Switch to another program when running program waits for

I/OMore work for OS. More complex management of

I I/OI MemoryI Processor

2012

-12-

06

CS34History

Multiprogrammed Batch Systems

Page 28: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

History

Time-Sharing Systems

Provide better environment for users—multiplex the processorbetween users:

I Run multiple independent programs at onceI Switch between users rapidly

I Illusion of having the machine’s full attention

Yet more complexity for OS:

24 / 36

Time-Sharing Systems

Provide better environment for users—multiplex the processorbetween users:

I Run multiple independent programs at onceI Switch between users rapidly

I Illusion of having the machine’s full attention

Yet more complexity for OS:

2012

-12-

06

CS34History

Time-Sharing Systems

Page 29: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

History

History Repeats Itself

As new, “smaller” hardware appears, it tends to repeat thisevolution

I Mini computersI Personal computersI PDAsI Embedded systems

I Cell phonesI MP3 PlayersI Cameras, etc.

25 / 36

History Repeats Itself

As new, “smaller” hardware appears, it tends to repeat thisevolution

I Mini computersI Personal computersI PDAsI Embedded systems

I Cell phonesI MP3 PlayersI Cameras, etc.

2012

-12-

06

CS34History

History Repeats Itself

Page 30: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Computer Hardware

tape drivesprinterdiskdisk

CPUdisk

controllerprinter

controllertape-drivecontroller

memory

memory controller

system bus

on-line

26 / 36

Computer Hardware

tape drivesprinterdiskdisk

CPUdisk

controllerprinter

controllertape-drivecontroller

memory

memory controller

system bus

on-line

2012

-12-

06

CS34Hardware

Computer Hardware

Page 31: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Computer Hardware—CPU & Memory

Need to perform computation!

Fetch Instruction

Execute InstructionStart

I Memory contains program instructions and program dataI Processor registers maintain processor state. Registers

include:I General purpose (address & data) registersI Instruction pointer (aka program counter)I Stack pointer(s)I Control and status registers

27 / 36

Computer Hardware—CPU & Memory

Need to perform computation!

Fetch Instruction

Execute InstructionStart

I Memory contains program instructions and program dataI Processor registers maintain processor state. Registers

include:I General purpose (address & data) registersI Instruction pointer (aka program counter)I Stack pointer(s)I Control and status registers20

12-1

2-06

CS34Hardware

Computer Hardware—CPU & Memory

Page 32: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Computer Hardware—I/O Devices

Need to communicate with the world!I I/O devices and CPU execute concurrentlyI Devices have hardware controllers

I Handles devices of a particular device typeI Some level of autonomyI Local buffer

I I/O is from the device to local buffer of controllertape drivesprinterdiskdisk

CPUdisk

controllerprinter

controllertape-drivecontroller

memory

memory controller

system bus

on-line

28 / 36

Computer Hardware—I/O Devices

Need to communicate with the world!I I/O devices and CPU execute concurrentlyI Devices have hardware controllers

I Handles devices of a particular device typeI Some level of autonomyI Local buffer

I I/O is from the device to local buffer of controllertape drivesprinterdiskdisk

CPUdisk

controllerprinter

controllertape-drivecontroller

memory

memory controller

system bus

on-line

2012

-12-

06

CS34Hardware

Computer Hardware—I/O Devices

Page 33: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Programmed I/O

After I/O starts, control returns to user program only on I/Ocompletion

I CPU waits until I/O completes.I At most one I/O request is outstanding at a time

I No simultaneous I/O processing

29 / 36

Programmed I/O

After I/O starts, control returns to user program only on I/Ocompletion

I CPU waits until I/O completes.I At most one I/O request is outstanding at a time

I No simultaneous I/O processing

2012

-12-

06

CS34Hardware

Programmed I/O

Page 34: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Polled I/O

Polling == Querying the I/O deviceSeparate I/O into two parts:

I InitiationI Polling

Advantages?

30 / 36

Polled I/O

Polling == Querying the I/O deviceSeparate I/O into two parts:

I InitiationI Polling

Advantages?

2012

-12-

06

CS34Hardware

Polled I/O

Page 35: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Interrupt-Driven I/O

Separate I/O into two parts:I InitiationI Asynchronous notification

31 / 36

Interrupt-Driven I/O

Separate I/O into two parts:I InitiationI Asynchronous notification

2012

-12-

06

CS34Hardware

Interrupt-Driven I/O

Page 36: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

I/O in User-Level Code

User-level code almost always uses “programmed I/O”(e.g. read and write on a file)

Why?

32 / 36

I/O in User-Level Code

User-level code almost always uses “programmed I/O”(e.g. read and write on a file)

Why?

2012

-12-

06

CS34Hardware

I/O in User-Level Code

Page 37: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Computer Hardware—CPU with Interrupts

CPU needs another feature. . .

Fetch Instruction

Execute InstructionStart

InterruptsEnabled?

No

Yes

Interrupt?No

Yes

Save StateJump to Handler

33 / 36

Computer Hardware—CPU with Interrupts

CPU needs another feature. . .

Fetch Instruction

Execute InstructionStart

InterruptsEnabled?

No

Yes

Interrupt?No

Yes

Save StateJump to Handler

2012

-12-

06

CS34Hardware

Computer Hardware—CPU with Interrupts

Page 38: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Handling an Interrupt

What needs to happen:I Save state

I All registersI Switch stacks?

I Find out what interrupt was. . .I PollingI Vectored interrupts

34 / 36

Handling an Interrupt

What needs to happen:I Save state

I All registersI Switch stacks?

I Find out what interrupt was. . .I PollingI Vectored interrupts

2012

-12-

06

CS34Hardware

Handling an Interrupt

Page 39: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Types of Interrupts

Various typesI Software exception (also called a trap)I TimerI I/OI Hardware failure

A modern operating system is interrupt driven

35 / 36

Types of Interrupts

Various typesI Software exception (also called a trap)I TimerI I/OI Hardware failure

A modern operating system is interrupt driven

2012

-12-

06

CS34Hardware

Types of Interrupts

Page 40: CS 134: Operating Systems · CS 134: Operating Systems ... OS X originates when the user manipulates an input device such as a mouse or a ... This kind of diagram suggests the general

Hardware

Other Hardware Features

We’ve covered interrupts, but hardware has other cool features,including:

I CachesI Memory managementI Protection

We’ll come back to hardware as we address these topics.

36 / 36

Other Hardware Features

We’ve covered interrupts, but hardware has other cool features,including:

I CachesI Memory managementI Protection

We’ll come back to hardware as we address these topics.

2012

-12-

06

CS34Hardware

Other Hardware Features