<<

CS34

CS 134: Operating Systems Definitions, Abstractions, Taxonomies, Early History 2012-12-06 CS 134: Operating Systems Definitions, Abstractions, Taxonomies, Early History

1 / 36 Overview CS34 Overview

What Is an OS?

Overview History

Hardware 2012-12-06

What Is an OS?

History

Hardware

2 / 36 What Is an OS?

What is an Operating System Anyway? CS34 What is an Operating System Anyway? What Is an OS?

Class Exercise: Devise three separate definitions. Discuss. What is an Operating System Anyway? 2012-12-06 Several slides follow that aren’t on handout.

Class Exercise: Devise three separate definitions. Discuss.

3 / 36 What Is an OS?

It’s A Programmer’s Toolkit CS34 It’s A Programmer’s Toolkit What Is an OS?

Provide useful functionality to programs:

I Prevent duplicated work It’s A Programmer’s Toolkit I Promote reuse 2012-12-06

Provide useful functionality to programs:

I Prevent duplicated work

I Promote reuse

4 / 36 What Is an OS?

It’s a Control Program CS34 It’s a Control Program What Is an OS?

Provide the rules for the how the machine will operate:

I Control the operation of the I/O devices It’s a Control Program I Ensure smooth running of the machine 2012-12-06

Provide the rules for the how the machine will operate:

I Control the operation of the I/O devices

I Ensure smooth running of the machine

5 / 36 What Is an OS?

It’s an Abstraction Layer CS34 It’s an Abstraction Layer What Is an OS? Make the machine “nicer”, easier to program, higher level. . . I Hide some of the idiosyncrasies of the machine

I Provide functionality the underlying machine doesn’t have It’s an Abstraction Layer 2012-12-06 Make the machine “nicer”, easier to program, higher level. . .

I Hide some of the idiosyncrasies of the machine

I Provide functionality the underlying machine doesn’t have

User

Application

Operating System

Hardware

6 / 36 CHAPTER 3 System Architecture

The Core Services and Application Services layers and the Carbon and Cocoa application environments are packaged in umbrella frameworks (described in the chapter “Umbrella Frameworks” (page 97)). Many public of the kernel environment are exported through headers found in /usr/include.

The first part of this chapter, as summarized in the foregoing paragraphs, presents the architecture of Mac OS X as layers of system . Following this static perspective of Mac OS X is a more dynamic view that traces the progress of a user event through the system. A typical event in Mac What Is anOS OS?X originates when the user manipulates an input device such as a mouse or a keyboard. The device driver associated with that device, through the I/O Kit, creates a low-level event, puts it in the window server’s event queue, and notifies the window server. The window server dispatches the event to the appropriate run-loop port of the target process. There the event is CS34 It’s an Abstraction Layer It’s an Abstraction Layerpicked up by the Carbon Event Manager and forwarded to the event-handling mechanism appropriate to the application environment. Events can also be asynchronous, such as a network What Is an OS? Make the machine “nicer”, easier to program, higher level. . . packet containing configuration changes. I Hide some of the idiosyncrasies of the machine I Provide functionality the underlying machine doesn’t have It’s an Abstraction Layer A Layered Perspective 2012-12-06

A common way to look at complex software is to separate out parts of that software into “layers.” Make the machine “nicer”, easierVisually depicted, to one program, layer sits on top of another, higher with the most level. fundamental .. layer on the bottom. This kind of diagram suggests the general interfaces and dependencies between the layers of software. The higher layers of software, which are the closest to actual application code, depend I Hide some of the idiosyncrasieson the layer immediately of under the them, machine and that intermediate layer depends on an even lower layer. I Provide functionality theMac underlying OS X is reducible to such machinea perspective. Figure 3-1 doesn’t (page 40) illustrates have the general structure of Mac OS X system software as interdependent layers of libraries, frameworks, and services.

Figure 3-1 Mac OS X as layers of system software User Application Classic Carbon Cocoa Java BSD environment (JDK)

Application Application Services QuickTime

Operating System Core Services

Kernel environment Hardware

Although this diagram does help clarify the overall architecture, there are dangers in the necessarily over-simplified view it presents. The Mac OS X services and subsystems that one application uses—and how it uses them—can be very different from those used by another application, even one of a similar type. Dependencies and interfaces at the different levels can vary 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 6 / 36 What Is an OS?

It’s a CS34 It’s a Virtual Machine

What Is an OS? OS provides an environment This environment can be seen as a “new machine”. . . Hardware —Physical machine + Core OS —Virtual machine + OS Libraries —Virtual machine It’s a Virtual Machine + OS Utilities —Virtual machine + Application —Virtual machine 2012-12-06

OS provides an environment This 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 What Is an OS?

It’s a Protection Layer CS34 It’s a Protection Layer What Is an OS?

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

I OS does everything programs can’t be trusted to do It’s a Protection Layer I OS makes programs play nice with others 2012-12-06

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

I OS does everything programs can’t be trusted to do

I OS makes programs play nice with others

8 / 36 Class Exercise: Examples?

Class Exercise: Examples?

What Is an OS?

It’s a Policy Enforcer CS34 It’s a Policy Enforcer What Is an OS?

OS provides the mechanisms to enforce various policies It’s a Policy Enforcer 2012-12-06

OS provides the mechanisms to enforce various policies

9 / 36 What Is an OS?

It’s a Policy Enforcer CS34 It’s a Policy Enforcer What Is an OS?

OS provides the mechanisms to enforce various policies It’s a Policy Enforcer Class Exercise: Examples? 2012-12-06

OS provides the mechanisms to enforce various policies

Class Exercise: Examples?

9 / 36 What Is an OS?

It’s a Resource Manager CS34 It’s a Resource Manager What Is an OS? The operating system manages physical resources:

I Processor

I Memory

I Storage devices It’s a Resource Manager I Network devices etc. . . 2012-12-06

The operating system manages physical resources:

I Processor

I Memory

I Storage devices

I Network devices etc. . .

10 / 36 What Is an OS?

It’s a Resource Manager (cont’d.) CS34 It’s a Resource Manager (cont’d.) What Is an OS? The operating system manages virtual resources:

I Processes

I Files

I Users It’s a Resource Manager (cont’d.) I Network connections I Windows etc.. . . 2012-12-06

The operating system manages virtual resources:

I Processes

I Files

I Users

I Network connections

I Windows etc.. . .

11 / 36 What Is an OS?

It’s a Product CS34 It’s a Product What Is an OS?

Many operating systems are sold by commercial companies

I Market vs. technical considerations

I The operating system is what comes in the box marked It’s a Product “operating system” 2012-12-06

Many operating systems are sold by commercial companies

I Market vs. technical considerations

I The operating system is what comes in the box marked “operating system”

12 / 36 What Is an OS?

Fundamental Abstractions CS34 Fundamental Abstractions What Is an OS?

What are the (user-level) abstractions we’d expect to find in a Fundamental Abstractions modern OS? 2012-12-06

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

13 / 36 What Is an OS?

Fundamental Abstractions CS34 Fundamental Abstractions What Is an OS? Include. . . I System calls I IPC Mechanisms I Processes I Semaphores I Threads I Mutexes I Address spaces I Condition Variables I Files I Communications channels I Files I Pipelines Fundamental Abstractions I Directories I Network connections I Filesystems I Events I Users

I Asynchronous I (Remote) Hosts I Synchronous Include. . . 2012-12-06

I System calls I IPC Mechanisms I Processes I Semaphores I Threads I Mutexes I Address spaces I Condition Variables I Files I Communications channels I Files I Pipelines I Directories I Network connections I Filesystems I Events I Users

I Asynchronous I (Remote) Hosts I Synchronous

14 / 36 What Is an OS?

It’s a Resource Manager CS34 It’s a Resource Manager What Is an OS?

What are the “resources” that an operating system manages? It’s a Resource Manager 2012-12-06

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

15 / 36 What Is an OS?

It’s a Resource Manager CS34 It’s a Resource Manager What Is an OS? The operating system manages physical resources:

I Processor

I Memory

I Storage devices It’s a Resource Manager I Network devices etc.. . . 2012-12-06

The operating system manages physical resources:

I Processor

I Memory

I Storage devices

I Network devices etc.. . .

16 / 36 What Is an OS?

It’s a Resource Manager (cont’d.) CS34 It’s a Resource Manager (cont’d.) What Is an OS? The operating system manages virtual resources:

I Processes

I Files

I Users It’s a Resource Manager (cont’d.) I Network connections I Windows etc.. . . 2012-12-06

The operating system manages virtual resources:

I Processes

I Files

I Users

I Network connections

I Windows etc.. . .

17 / 36 Class Exercise: Give some dimensions across which computer systems vary

Class Exercise: Give some dimensions across which computer systems vary

What Is an OS?

Taxonomy of Computer Systems CS34 Taxonomy of Computer Systems What Is an OS?

Different computer systems ask different things from their OS Taxonomy of Computer Systems 2012-12-06

Different computer systems ask different things from their OS

18 / 36 What Is an OS?

Taxonomy of Computer Systems CS34 Taxonomy of Computer Systems What Is an OS?

Different computer systems ask different things from their OS

Class Exercise: Give some dimensions across which computer Taxonomy of Computer Systems systems vary 2012-12-06

Different computer systems ask different things from their OS

Class Exercise: Give some dimensions across which computer systems vary

18 / 36 What Is an OS?

CS34 Partial Taxonomy of Computer Systems Partial Taxonomy of Computer Systems Different computer systems ask different things from their OS: Special-purpose ↔ General-purpose What Is an OS? Single-user ↔ Multi-user Non–Resource-sharing ↔ Resource sharing Single processor ↔ Multiprocessor Stand alone ↔ Networked Centralized ↔ Distributed Batch ↔ Interactive Different computer systems ask different things from their OS: Partial Taxonomy of Computer Systems Deadline-free ↔ Real-time Insecure ↔ Secure Symmetric ↔ Asymmetric Simple ↔ Complex Small ↔ Large 2012-12-06 Inexpensive ↔ Expensive Special-purpose ↔ General-purpose etc. Single-user ↔ Multi-user Non–Resource-sharing ↔ Resource sharing Single processor ↔ Multiprocessor Stand alone ↔ Networked Centralized ↔ Distributed Batch ↔ Interactive Deadline-free ↔ Real-time Insecure ↔ Secure Symmetric ↔ Asymmetric Simple ↔ Complex Small ↔ Large Inexpensive ↔ Expensive etc.

19 / 36 History

Early Computers CS34 Early Computers

History 1950s—large complex machines

I Operated directly from a console

I Used interactively by a single user

I Ran one program at a time (uniprogramming)

I Read from paper tape, punched cards, or toggle Early Computers switches OS? Maybe a library containing code to work the I/O devices was useful. 2012-12-06

1950s—large complex machines

I Operated directly from a console

I Used interactively by a single user

I Ran one program at a time (uniprogramming)

I Read data from paper tape, punched cards, or toggle switches OS? Maybe a library containing code to work the I/O devices was useful.

20 / 36 History

CS34 Simple Batch Systems Simple Batch Systems Provide better use of resources: History I Users access computer indirectly I Programs and input (jobs) taken from a batch queue

I Computer has a human operator to feed it jobs Simple Batch Systems

Provide better use of resources: Need to:

2012-12-06 I Manage the jobs:

I Protect the next program from the previous program I Users access computer indirectly

I Programs and input (jobs) taken from a batch queue

I Computer has a human operator to feed it jobs

Tape System drive Input tape Output Card tape tape reader Printer

1401 7094 1401

Need to:

I Manage the jobs:

I Protect the next program from the previous program

21 / 36 Class Exercise: Why does buffering improve performance? Does buffering always improve performance? (What assumptions are we making?)

Class Exercise: Why does buffering improve performance? Does buffering always improve performance? (What assumptions are we making?)

History

SPOOLing Batch Systems CS34 SPOOLing Batch Systems History Provide better use of resources—buffer input and output

I Read-ahead input from disk/tape

I Write-behind output to disk/tape SPOOLing Batch Systems 2012-12-06

Provide better use of resources—buffer input and output

I Read-ahead input from disk/tape

I Write-behind output to disk/tape

22 / 36 History

SPOOLing Batch Systems CS34 SPOOLing Batch Systems History Provide better use of resources—buffer input and output

I Read-ahead input from disk/tape

I Write-behind output to disk/tape Class Exercise: Why does buffering improve performance? SPOOLing Batch Systems Does buffering always improve performance? (What assumptions are we making?) 2012-12-06

Provide better use of resources—buffer input and output

I Read-ahead input from disk/tape

I 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 History

Multiprogrammed Batch Systems CS34 Multiprogrammed Batch Systems

History Provide better use of resources—multiplex the processor:

I Run multiple independent programs at once

I Switch to another program when running program waits for I/O More work for OS. More complex management of Multiprogrammed Batch Systems I I/O I Memory

I Processor 2012-12-06

Provide better use of resources—multiplex the processor:

I Run multiple independent programs at once

I Switch to another program when running program waits for I/O More work for OS. More complex management of

I I/O

I Memory

I Processor

23 / 36 History

Time-Sharing Systems CS34 Time-Sharing Systems History Provide better environment for users—multiplex the processor between users:

I Run multiple independent programs at once I Switch between users rapidly Time-Sharing Systems I Illusion of having the machine’s full attention Yet more complexity for OS: 2012-12-06

Provide better environment for users—multiplex the processor between users:

I Run multiple independent programs at once I Switch between users rapidly

I Illusion of having the machine’s full attention Yet more complexity for OS:

24 / 36 History

History Repeats Itself CS34 History Repeats Itself History As new, “smaller” hardware appears, it tends to repeat this evolution

I Mini computers

I Personal computers

I PDAs History Repeats Itself I Embedded systems I Cell phones I MP3 Players I Cameras, etc. 2012-12-06

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

I Mini computers

I Personal computers

I PDAs I Embedded systems

I Cell phones I MP3 Players I Cameras, etc.

25 / 36 Hardware

Computer Hardware CS34 Hardware

disk disk printer tape drives Computer Hardware

on-line 2012-12-06

disk printer tape-drive CPU controller controller controller

system bus

memory controller

memory

26 / 36 Hardware

Computer Hardware—CPU & Memory CS34 Computer Hardware—CPU & Memory Hardware Need to perform computation!

I Memory contains program instructions and program data I Processor registers maintain processor state. Registers Computer Hardware—CPU & Memory include:

I General purpose (address & data) registers I Instruction pointer (aka program counter) I Stack pointer(s) I Control and status registers Need to perform computation! 2012-12-06

Fetch Execute Start Instruction Instruction

I Memory contains program instructions and program data I Processor registers maintain processor state. Registers include:

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

27 / 36 Hardware

CS34 Computer Hardware—I/O Devices Computer Hardware—I/O Devices Need to communicate with the world! I I/O devices and CPU execute concurrently Hardware I Devices have hardware controllers I Handles devices of a particular device type I Some level of autonomy I Local buffer I I/O is from the device to local buffer of controller Need to communicate with the world! Computer Hardware—I/O Devices

I I/O devices and CPU execute concurrently 2012-12-06 I Devices have hardware controllers

I Handles devices of a particular device type I Some level of autonomy I Local buffer I I/O is from the device to local buffer of controller

disk disk printer tape drives

on-line

disk printer tape-drive CPU controller controller controller

system bus

memory controller

memory

28 / 36 Hardware

Programmed I/O CS34 Programmed I/O Hardware After I/O starts, control returns to user program only on I/O completion

I CPU waits until I/O completes. I At most one I/O request is outstanding at a time Programmed I/O I No simultaneous I/O processing 2012-12-06

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

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 Hardware

Polled I/O CS34 Polled I/O Hardware Polling == Querying the I/O device Separate I/O into two parts:

I Initiation

I Polling Polled I/O Advantages? 2012-12-06

Polling == Querying the I/O device Separate I/O into two parts:

I Initiation

I Polling Advantages?

30 / 36 Hardware

Interrupt-Driven I/O CS34 Interrupt-Driven I/O Hardware

Separate I/O into two parts:

I Initiation Interrupt-Driven I/O I Asynchronous notification 2012-12-06

Separate I/O into two parts:

I Initiation

I Asynchronous notification

31 / 36 Hardware

I/O in User-Level Code CS34 I/O in User-Level Code Hardware

User-level code almost always uses “programmed I/O” (e.g. read and write on a file) I/O in User-Level Code Why? 2012-12-06

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

Why?

32 / 36 Hardware

CS34 Computer Hardware—CPU with Interrupts Computer Hardware—CPU with Interrupts CPU needs another feature. . . Hardware

CPU needs another feature. . . Computer Hardware—CPU with Interrupts 2012-12-06 Fetch Execute Start Instruction Instruction

No Interrupts Enabled?

Yes

No Interrupt?

Yes

Jump to Save State Handler

33 / 36 Hardware

Handling an Interrupt CS34 Handling an Interrupt Hardware What needs to happen: I Save state

I All registers I Switch stacks? Handling an Interrupt I Find out what interrupt was. . . I Polling I Vectored interrupts 2012-12-06

What needs to happen: I Save state

I All registers I Switch stacks? I Find out what interrupt was. . .

I Polling I Vectored interrupts

34 / 36 Hardware

Types of Interrupts CS34 Types of Interrupts Hardware Various types

I Software exception (also called a trap)

I Timer

I I/O Types of Interrupts I Hardware failure A modern operating system is interrupt driven 2012-12-06

Various types

I Software exception (also called a trap)

I Timer

I I/O

I Hardware failure A modern operating system is interrupt driven

35 / 36 Hardware

Other Hardware Features CS34 Other Hardware Features Hardware We’ve covered interrupts, but hardware has other cool features, including:

I Caches

I Memory management Other Hardware Features I Protection We’ll come back to hardware as we address these topics. 2012-12-06

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

I Caches

I Memory management

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

36 / 36