CS 134: Operating Systems
Definitions, Abstractions, Taxonomies, Early History
1 / 36
CS 134: Operating Systems
Definitions, Abstractions, Taxonomies, Early History
2012-12-06
CS34
CS 134: Operating Systems Definitions, Abstractions, Taxonomies, - - PowerPoint PPT Presentation
CS34 2012-12-06 CS 134: Operating Systems Definitions, Abstractions, Taxonomies, Early History CS 134: Operating Systems Definitions, Abstractions, Taxonomies, Early History 1 / 36 Overview CS34 Overview 2012-12-06 What Is an OS?
1 / 36
CS 134: Operating Systems
Definitions, Abstractions, Taxonomies, Early History
CS34
2 / 36
Overview
What Is an OS? History Hardware
CS34 Overview
What Is an OS?
3 / 36
What is an Operating System Anyway?
Class Exercise: Devise three separate definitions. Discuss.
CS34 What Is an OS? What is an Operating System Anyway?
What Is an OS?
4 / 36
It’s A Programmer’s Toolkit
Provide useful functionality to programs:
◮ Prevent duplicated work ◮ Promote reuse
CS34 What Is an OS? It’s A Programmer’s Toolkit
What Is an OS?
5 / 36
It’s a Control Program
Provide the rules for the how the machine will operate:
◮ Control the operation of the I/O devices ◮ Ensure smooth running of the machine
CS34 What Is an OS? It’s a Control Program
What Is an OS?
6 / 36
It’s an Abstraction Layer
Make the machine “nicer”, easier to program, higher level. . .
◮ Hide some of the idiosyncrasies of the machine ◮ Provide functionality the underlying machine doesn’t have Hardware Operating System Application User
CS34 What Is an OS? It’s an Abstraction Layer
What Is an OS?
BSD Carbon Cocoa Java (JDK) BSD Classic Core Services Kernel environment QuickTime Application Services Application environment
6 / 36
It’s an Abstraction Layer
Make the machine “nicer”, easier to program, higher level. . .
◮ Hide some of the idiosyncrasies of the machine ◮ Provide functionality the underlying machine doesn’t have Hardware Operating System Application User
BSD Carbon Cocoa Java (JDK) BSD Classic Core Services Kernel environment QuickTime Application Services Application environmentCS34 What Is an OS? It’s an Abstraction Layer
What Is an OS?
7 / 36
It’s a Virtual Machine
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
CS34 What Is an OS? It’s a Virtual Machine
What Is an OS?
8 / 36
It’s a Protection Layer
Make the machine more robust—less scope for a bug to have devastating consequences
◮ OS does everything programs can’t be trusted to do ◮ OS makes programs play nice with others
CS34 What Is an OS? It’s a Protection Layer
What Is an OS?
9 / 36
It’s a Policy Enforcer
OS provides the mechanisms to enforce various policies
CS34 What Is an OS? It’s a Policy Enforcer
What Is an OS?
9 / 36
It’s a Policy Enforcer
OS provides the mechanisms to enforce various policies Class Exercise: Examples?
CS34 What Is an OS? It’s a Policy Enforcer
What Is an OS?
10 / 36
It’s a Resource Manager
The operating system manages physical resources:
◮ Processor ◮ Memory ◮ Storage devices ◮ Network devices
CS34 What Is an OS? It’s a Resource Manager
What Is an OS?
11 / 36
It’s a Resource Manager (cont’d.)
The operating system manages virtual resources:
◮ Processes ◮ Files ◮ Users ◮ Network connections ◮ Windows
etc.. . .
CS34 What Is an OS? It’s a Resource Manager (cont’d.)
What Is an OS?
12 / 36
It’s a Product
Many operating systems are sold by commercial companies
◮ Market vs. technical considerations ◮ The operating system is what comes in the box marked
“operating system”
CS34 What Is an OS? It’s a Product
What Is an OS?
13 / 36
Fundamental Abstractions
What are the (user-level) abstractions we’d expect to find in a modern OS?
CS34 What Is an OS? Fundamental Abstractions
What Is an OS?
◮ Threads ◮ Address spaces
◮ Files ◮ Directories ◮ Filesystems
◮ Asynchronous ◮ Synchronous
◮ Semaphores ◮ Mutexes ◮ Condition Variables
◮ Pipelines ◮ Network connections
14 / 36
Fundamental Abstractions
◮ System calls ◮ Processes ◮ Threads ◮ Address spaces ◮ Files ◮ Files ◮ Directories ◮ Filesystems ◮ Events ◮ Asynchronous ◮ Synchronous ◮ IPC Mechanisms ◮ Semaphores ◮ Mutexes ◮ Condition Variables ◮ Communications channels ◮ Pipelines ◮ Network connections ◮ Users ◮ (Remote) Hosts
CS34 What Is an OS? Fundamental Abstractions
What Is an OS?
15 / 36
It’s a Resource Manager
What are the “resources” that an operating system manages?
CS34 What Is an OS? It’s a Resource Manager
What Is an OS?
16 / 36
It’s a Resource Manager
The operating system manages physical resources:
◮ Processor ◮ Memory ◮ Storage devices ◮ Network devices
etc.. . .
CS34 What Is an OS? It’s a Resource Manager
What Is an OS?
17 / 36
It’s a Resource Manager (cont’d.)
The operating system manages virtual resources:
◮ Processes ◮ Files ◮ Users ◮ Network connections ◮ Windows
etc.. . .
CS34 What Is an OS? It’s a Resource Manager (cont’d.)
What Is an OS?
18 / 36
Taxonomy of Computer Systems
Different computer systems ask different things from their OS
CS34 What Is an OS? Taxonomy of Computer Systems
What Is an OS?
18 / 36
Taxonomy of Computer Systems
Different computer systems ask different things from their OS Class Exercise: Give some dimensions across which computer systems vary
CS34 What Is an OS? Taxonomy of Computer Systems
What Is an OS?
19 / 36
Partial Taxonomy of Computer Systems
Different computer systems ask different things from their OS: Special-purpose ↔ General-purpose 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.
CS34 What Is an OS? Partial Taxonomy of Computer Systems
History
20 / 36
Early Computers
1950s—large complex machines
◮ Operated directly from a console ◮ Used interactively by a single user ◮ Ran one program at a time (uniprogramming) ◮ Read data from paper tape, punched cards, or toggle
switches OS? Maybe a library containing code to work the I/O devices was useful.
CS34 History Early Computers
History
1401 7094 1401 Card reader Tape drive Input tape Output tape System tape Printer
21 / 36
Simple Batch Systems
Provide better use of resources:
◮ Users access computer indirectly ◮ Programs and input (jobs) taken from a batch queue ◮ Computer has a human operator to feed it jobs 1401 7094 1401 Card reader Tape drive Input tape Output tape System tape Printer
Need to:
◮ Manage the jobs: ◮ Protect the next program from the previous program
CS34 History Simple Batch Systems
History
22 / 36
SPOOLing Batch Systems
Provide better use of resources—buffer input and output
◮ Read-ahead input from disk/tape ◮ Write-behind output to disk/tape
CS34 History SPOOLing Batch Systems
History
22 / 36
SPOOLing Batch Systems
Provide better use of resources—buffer input and output
◮ Read-ahead input from disk/tape ◮ Write-behind output to disk/tape
Class Exercise: Why does buffering improve performance? Does buffering always improve performance? (What assumptions are we making?)
CS34 History SPOOLing Batch Systems
History
23 / 36
Multiprogrammed Batch Systems
Provide better use of resources—multiplex the processor:
◮ Run multiple independent programs at once ◮ Switch to another program when running program waits for
I/O More work for OS. More complex management of
◮ I/O ◮ Memory ◮ Processor
CS34 History Multiprogrammed Batch Systems
History
◮ Illusion of having the machine’s full attention
24 / 36
Time-Sharing Systems
Provide better environment for users—multiplex the processor between users:
◮ Run multiple independent programs at once ◮ Switch between users rapidly ◮ Illusion of having the machine’s full attention
Yet more complexity for OS:
CS34 History Time-Sharing Systems
History
◮ Cell phones ◮ MP3 Players ◮ Cameras, etc. 25 / 36
History Repeats Itself
As new, “smaller” hardware appears, it tends to repeat this evolution
◮ Mini computers ◮ Personal computers ◮ PDAs ◮ Embedded systems ◮ Cell phones ◮ MP3 Players ◮ Cameras, etc.
CS34 History History Repeats Itself
Hardware
tape drives printer disk disk CPU disk controller printer controller tape-drive controller memory memory controller system bus
26 / 36
Computer Hardware
tape drives printer disk disk CPU disk controller printer controller tape-drive controller memory memory controller system bus
CS34 Hardware Computer Hardware
Hardware
◮ General purpose (address & data) registers ◮ Instruction pointer (aka program counter) ◮ Stack pointer(s) ◮ Control and status registers 27 / 36
Computer Hardware—CPU & Memory
Need to perform computation! Fetch Instruction Execute Instruction Start
◮ Memory contains program instructions and program data ◮ Processor registers maintain processor state. Registers
include:
◮ General purpose (address & data) registers ◮ Instruction pointer (aka program counter) ◮ Stack pointer(s) ◮ Control and status registersCS34 Hardware Computer Hardware—CPU & Memory
Hardware
◮ Handles devices of a particular device type ◮ Some level of autonomy ◮ Local buffer
tape drives printer disk disk CPU disk controller printer controller tape-drive controller memory memory controller system bus
28 / 36
Computer Hardware—I/O Devices
Need to communicate with the world!
◮ I/O devices and CPU execute concurrently ◮ Devices have hardware controllers ◮ Handles devices of a particular device type ◮ Some level of autonomy ◮ Local buffer ◮ I/O is from the device to local buffer of controller
tape drives printer disk disk CPU disk controller printer controller tape-drive controller memory memory controller system busCS34 Hardware Computer Hardware—I/O Devices
Hardware
◮ No simultaneous I/O processing 29 / 36
Programmed I/O
After I/O starts, control returns to user program only on I/O completion
◮ CPU waits until I/O completes. ◮ At most one I/O request is outstanding at a time ◮ No simultaneous I/O processing
CS34 Hardware Programmed I/O
Hardware
30 / 36
Polled I/O
Polling == Querying the I/O device Separate I/O into two parts:
◮ Initiation ◮ Polling
Advantages?
CS34 Hardware Polled I/O
Hardware
31 / 36
Interrupt-Driven I/O
Separate I/O into two parts:
◮ Initiation ◮ Asynchronous notification
CS34 Hardware Interrupt-Driven I/O
Hardware
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?
CS34 Hardware I/O in User-Level Code
Hardware
Fetch Instruction Execute Instruction Start Interrupts Enabled? No Yes Interrupt? No Yes Save State Jump to Handler
33 / 36
Computer Hardware—CPU with Interrupts
CPU needs another feature. . .
Fetch Instruction Execute Instruction Start Interrupts Enabled? No Yes Interrupt? No Yes Save State Jump to Handler
CS34 Hardware Computer Hardware—CPU with Interrupts
Hardware
◮ All registers ◮ Switch stacks?
◮ Polling ◮ Vectored interrupts 34 / 36
Handling an Interrupt
What needs to happen:
◮ Save state ◮ All registers ◮ Switch stacks? ◮ Find out what interrupt was. . . ◮ Polling ◮ Vectored interrupts
CS34 Hardware Handling an Interrupt
Hardware
35 / 36
Types of Interrupts
Various types
◮ Software exception (also called a trap) ◮ Timer ◮ I/O ◮ Hardware failure
A modern operating system is interrupt driven
CS34 Hardware Types of Interrupts
Hardware
36 / 36
Other Hardware Features
We’ve covered interrupts, but hardware has other cool features, including:
◮ Caches ◮ Memory management ◮ Protection
We’ll come back to hardware as we address these topics.
CS34 Hardware Other Hardware Features