Download Operating Systems - HMC Computer Science

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Unix security wikipedia , lookup

Distributed operating system wikipedia , lookup

Copland (operating system) wikipedia , lookup

Burroughs MCP wikipedia , lookup

VS/9 wikipedia , lookup

CP/M wikipedia , lookup

Transcript
2012-12-06
CS 134:
Operating Systems
Definitions, Abstractions, Taxonomies, Early History
1 / 36
CS34
CS 134:
Operating Systems
Definitions, Abstractions, Taxonomies, Early History
2012-12-06
Overview
What Is an OS?
History
Hardware
2 / 36
CS34
Overview
What Is an OS?
Overview
History
Hardware
What Is an OS?
2012-12-06
What is an Operating System Anyway?
CS34
What Is an OS?
What is an Operating System Anyway?
What is an Operating System Anyway?
Class Exercise: Devise three separate definitions. Discuss.
Several slides follow that aren’t on
handout.
Class Exercise: Devise three separate definitions. Discuss.
3 / 36
What Is an OS?
2012-12-06
It’s A Programmer’s Toolkit
Provide useful functionality to programs:
I
Prevent duplicated work
I
Promote reuse
4 / 36
CS34
What Is an OS?
It’s A Programmer’s Toolkit
Provide useful functionality to programs:
It’s A Programmer’s Toolkit
I
Prevent duplicated work
I
Promote reuse
What Is an OS?
2012-12-06
It’s a Control Program
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
CS34
What Is an OS?
It’s a Control Program
Provide the rules for the how the machine will operate:
It’s a Control Program
I
Control the operation of the I/O devices
I
Ensure smooth running of the machine
What Is an OS?
2012-12-06
It’s an Abstraction Layer
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
CS34
What Is an OS?
It’s an Abstraction Layer
It’s an Abstraction Layer
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
dynamic view that traces the progress of a user event through the system. A typical event in Mac
C H A P T E R
OSOS?
X originates when the user manipulates an input device such as a mouse or a keyboard. The
What Is an
It’s an Abstraction Layer
A Layered Perspective
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 APIs of the kernel environment are exported through
headers found in /usr/include.
2012-12-06
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
picked 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
packet containing configuration changes.
CS34
What Is an OS?
The first part of this chapter, as summarized in the foregoing paragraphs, presents the architecture
of Mac OS X as layers of system software. 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
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
picked 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
packet containing configuration changes.
It’s an Abstraction Layer
A Layered Perspective
A common way to look at complex software is to separate out parts of that software into “layers.”
Make the machine “nicer”, easier
to one
program,
higher
level.
. .layer on the bottom.
Visually depicted,
layer sits on top of another,
with the most
fundamental
This kind of diagram suggests the general interfaces and dependencies between the layers of
I
software. The higher layers of software, which are the closest to actual application code, depend
Hide some of the idiosyncrasies
ofunder
the
machine
on the layer immediately
them,
and that intermediate layer depends on an even lower
I
OS X is reducible to suchmachine
a perspective. Figure 3-1
(page 40) illustrates
the general structure
Provide functionality theofMacunderlying
doesn’t
have
Mac OS X system software as interdependent layers of libraries, frameworks, and services.
layer.
It’s an Abstraction Layer
Figure 3-1
Mac OS X as layers of system software
Application
environment
Classic
User
Application
Carbon
Cocoa
Java
(JDK)
Application Services
Operating System
BSD
BSD
QuickTime
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.
A common way to look at complex software is to separate out parts of that software into “layers.”
Make the machine “nicer”, easier
to one
program,
higher
level.
. .layer on the bottom.
Visually depicted,
layer sits on top of another,
with the most
fundamental
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
on the layer immediately under them, and that intermediate layer depends on an even lower
layer.
I
Hide some of the idiosyncrasies of the machine
I
OS X is reducible to suchmachine
a perspective. Figure 3-1
(page 40) illustrates
the general structure
Provide functionality theMac
underlying
doesn’t
have
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
Application
environment
Classic
User
Application
Carbon
Cocoa
Java
(JDK)
Application Services
Operating System
BSD
BSD
QuickTime
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
40
A Layered Perspective
© Apple Computer, Inc. 2003
What Is an OS?
2012-12-06
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
+ OS Utilities
+ Application
—Virtual machine
—Virtual machine
—Virtual machine
7 / 36
CS34
What Is an OS?
It’s a Virtual Machine
OS provides an environment
This environment can be seen as a “new machine”. . .
Hardware
It’s a Virtual Machine
—Physical machine
+ Core OS
—Virtual machine
+ OS Libraries
+ OS Utilities
+ Application
—Virtual machine
—Virtual machine
—Virtual machine
What Is an OS?
2012-12-06
It’s a Protection Layer
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
CS34
What Is an OS?
It’s a Protection Layer
Make the machine more robust—less scope for a bug to have
devastating consequences
It’s a Protection Layer
I
OS does everything programs can’t be trusted to do
I
OS makes programs play nice with others
What Is an OS?
2012-12-06
It’s a Policy Enforcer
OS provides the mechanisms to enforce various policies
9 / 36
CS34
What Is an OS?
It’s a Policy Enforcer
OS provides the mechanisms to enforce various policies
It’s a Policy Enforcer
What Is an OS?
2012-12-06
It’s a Policy Enforcer
OS provides the mechanisms to enforce various policies
Class Exercise: Examples?
9 / 36
CS34
What Is an OS?
It’s a Policy Enforcer
OS provides the mechanisms to enforce various policies
It’s a Policy Enforcer
Class Exercise: Examples?
What Is an OS?
2012-12-06
It’s a Resource Manager
The operating system manages physical resources:
I
Processor
I
Memory
I
Storage devices
I
Network devices
etc. . .
10 / 36
CS34
What Is an OS?
It’s a Resource Manager
The operating system manages physical resources:
It’s a Resource Manager
I
Processor
I
Memory
I
Storage devices
I
Network devices
etc. . .
What Is an OS?
2012-12-06
It’s a Resource Manager (cont’d.)
The operating system manages virtual resources:
I
Processes
I
Files
I
Users
I
Network connections
I
Windows
etc.. . .
11 / 36
CS34
What Is an OS?
It’s a Resource Manager (cont’d.)
It’s a Resource Manager (cont’d.)
The operating system manages virtual resources:
I
Processes
I
Files
I
Users
I
Network connections
I
Windows
etc.. . .
What Is an OS?
2012-12-06
It’s a Product
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
CS34
What Is an OS?
It’s a Product
Many operating systems are sold by commercial companies
It’s a Product
I
Market vs. technical considerations
I
The operating system is what comes in the box marked
“operating system”
What Is an OS?
2012-12-06
Fundamental Abstractions
What are the (user-level) abstractions we’d expect to find in a
modern OS?
13 / 36
CS34
What Is an OS?
Fundamental Abstractions
Fundamental Abstractions
What are the (user-level) abstractions we’d expect to find in a
modern OS?
What Is an OS?
2012-12-06
Fundamental Abstractions
Include. . .
I
I
System calls
Processes
I
I
I
I
I
I
I
I
I
I
I
Files
Directories
Filesystems
Events
Asynchronous
Synchronous
IPC Mechanisms
I
Threads
Address spaces
Files
I
I
Communications channels
I
I
I
I
Semaphores
Mutexes
Condition Variables
Pipelines
Network connections
Users
(Remote) Hosts
14 / 36
CS34
What Is an OS?
Fundamental Abstractions
Include. . .
I
I
System calls
Processes
I
Files
I
I
Fundamental Abstractions
I
I
I
I
I
IPC Mechanisms
I
Communications channels
I
I
I
Files
Directories
Filesystems
Events
I
I
Threads
Address spaces
Asynchronous
Synchronous
I
I
I
I
Semaphores
Mutexes
Condition Variables
Pipelines
Network connections
Users
(Remote) Hosts
What Is an OS?
2012-12-06
It’s a Resource Manager
What are the “resources” that an operating system manages?
15 / 36
CS34
What Is an OS?
It’s a Resource Manager
What are the “resources” that an operating system manages?
It’s a Resource Manager
What Is an OS?
2012-12-06
It’s a Resource Manager
The operating system manages physical resources:
I
Processor
I
Memory
I
Storage devices
I
Network devices
etc.. . .
16 / 36
CS34
What Is an OS?
It’s a Resource Manager
The operating system manages physical resources:
It’s a Resource Manager
I
Processor
I
Memory
I
Storage devices
I
Network devices
etc.. . .
What Is an OS?
2012-12-06
It’s a Resource Manager (cont’d.)
The operating system manages virtual resources:
I
Processes
I
Files
I
Users
I
Network connections
I
Windows
etc.. . .
17 / 36
CS34
What Is an OS?
It’s a Resource Manager (cont’d.)
It’s a Resource Manager (cont’d.)
The operating system manages virtual resources:
I
Processes
I
Files
I
Users
I
Network connections
I
Windows
etc.. . .
What Is an OS?
2012-12-06
Taxonomy of Computer Systems
Different computer systems ask different things from their OS
18 / 36
CS34
What Is an OS?
Taxonomy of Computer Systems
Different computer systems ask different things from their OS
Taxonomy of Computer Systems
What Is an OS?
2012-12-06
Taxonomy of Computer Systems
Different computer systems ask different things from their OS
Class Exercise: Give some dimensions across which computer
systems vary
18 / 36
CS34
What Is an OS?
Taxonomy of Computer Systems
Different computer systems ask different things from their OS
Taxonomy of Computer Systems
Class Exercise: Give some dimensions across which computer
systems vary
What Is an OS?
2012-12-06
Partial Taxonomy of Computer Systems
Different computer systems ask different things from their OS:
Special-purpose
Single-user
Non–Resource-sharing
Single processor
Stand alone
Centralized
Batch
Deadline-free
Insecure
Symmetric
Simple
Small
Inexpensive
↔
↔
↔
↔
↔
↔
↔
↔
↔
↔
↔
↔
↔
etc.
General-purpose
Multi-user
Resource sharing
Multiprocessor
Networked
Distributed
Interactive
Real-time
Secure
Asymmetric
Complex
Large
Expensive
19 / 36
CS34
What Is an OS?
Partial Taxonomy of Computer Systems
Partial Taxonomy of Computer Systems
Different computer systems ask different things from their OS:
Special-purpose
Single-user
Non–Resource-sharing
Single processor
Stand alone
Centralized
Batch
Deadline-free
Insecure
Symmetric
Simple
Small
Inexpensive
↔
↔
↔
↔
↔
↔
↔
↔
↔
↔
↔
↔
↔
etc.
General-purpose
Multi-user
Resource sharing
Multiprocessor
Networked
Distributed
Interactive
Real-time
Secure
Asymmetric
Complex
Large
Expensive
History
2012-12-06
Early Computers
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
CS34
History
Early Computers
1950s—large complex machines
I
Early Computers
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.
History
2012-12-06
Simple Batch Systems
Provide better use of resources:
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
Card
reader
Tape
drive
Input
tape
System
tape
Output
tape
Printer
1401
7094
1401
Need to:
I
Manage the jobs:
I
Protect the next program from the previous program
21 / 36
CS34
History
Simple Batch Systems
Provide better use of resources:
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
Card
reader
Simple Batch Systems
Tape
drive
Input
tape
System
tape
Output
tape
Printer
1401
7094
1401
Need to:
I
Manage the jobs:
I
Protect the next program from the previous program
History
2012-12-06
SPOOLing Batch Systems
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
CS34
History
SPOOLing Batch Systems
Provide better use of resources—buffer input and output
SPOOLing Batch Systems
I
Read-ahead input from disk/tape
I
Write-behind output to disk/tape
History
2012-12-06
SPOOLing Batch Systems
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
CS34
History
SPOOLing Batch Systems
Provide better use of resources—buffer input and output
SPOOLing Batch Systems
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?)
History
2012-12-06
Multiprogrammed Batch Systems
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
CS34
History
Multiprogrammed Batch Systems
Provide better use of resources—multiplex the processor:
Multiprogrammed Batch Systems
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
History
2012-12-06
Time-Sharing Systems
Provide better environment for users—multiplex the processor
between users:
I
I
Run multiple independent programs at once
Switch between users rapidly
I
Illusion of having the machine’s full attention
Yet more complexity for OS:
24 / 36
CS34
History
Time-Sharing Systems
Provide better environment for users—multiplex the processor
between users:
I
Time-Sharing Systems
I
Run multiple independent programs at once
Switch between users rapidly
I
Illusion of having the machine’s full attention
Yet more complexity for OS:
History
2012-12-06
History Repeats Itself
As new, “smaller” hardware appears, it tends to repeat this
evolution
I
Mini computers
I
Personal computers
I
PDAs
Embedded systems
I
I
I
I
Cell phones
MP3 Players
Cameras, etc.
25 / 36
CS34
History
History Repeats Itself
As new, “smaller” hardware appears, it tends to repeat this
evolution
History Repeats Itself
I
Mini computers
I
Personal computers
I
PDAs
Embedded systems
I
I
I
I
Cell phones
MP3 Players
Cameras, etc.
Hardware
disk
disk
printer
2012-12-06
Computer Hardware
tape drives
on-line
CS34
Hardware
Computer Hardware
disk
disk
printer
CPU
printer
controller
Computer Hardware
disk
controller
printer
controller
tape-drive
controller
system bus
memory controller
memory
26 / 36
tape-drive
controller
system bus
memory controller
memory
CPU
tape drives
on-line
disk
controller
Hardware
2012-12-06
Computer Hardware—CPU & Memory
Need to perform computation!
Start
I
I
Fetch
Instruction
Execute
Instruction
Memory contains program instructions and program data
Processor registers maintain processor state. Registers
include:
I
I
I
I
General purpose (address & data) registers
Instruction pointer (aka program counter)
Stack pointer(s)
Control and status registers
27 / 36
CS34
Hardware
Computer Hardware—CPU & Memory
Need to perform computation!
Start
Computer Hardware—CPU & Memory
I
I
Fetch
Instruction
Execute
Instruction
Memory contains program instructions and program data
Processor registers maintain processor state. Registers
include:
I
I
I
I
General purpose (address & data) registers
Instruction pointer (aka program counter)
Stack pointer(s)
Control and status registers
Hardware
2012-12-06
Computer Hardware—I/O Devices
Need to communicate with the world!
I I/O devices and CPU execute concurrently
I Devices have hardware controllers
I
I
I
I
I/O is from the device to local buffer of controller
disk
printer
tape drives
on-line
CPU
disk
controller
printer
controller
Computer Hardware—I/O Devices
Need to communicate with the world!
I I/O devices and CPU execute concurrently
I Devices have hardware controllers
I
I
I
I
Handles devices of a particular device type
Some level of autonomy
Local buffer
I/O is from the device to local buffer of controller
Computer Hardware—I/O Devices
disk
disk
printer
tape-drive
controller
system bus
memory controller
memory
28 / 36
tape drives
on-line
CPU
disk
controller
printer
controller
tape-drive
controller
system bus
memory controller
memory
Handles devices of a particular device type
Some level of autonomy
Local buffer
disk
CS34
Hardware
Hardware
2012-12-06
Programmed I/O
After I/O starts, control returns to user program only on I/O
completion
I
I
CPU waits until I/O completes.
At most one I/O request is outstanding at a time
I
No simultaneous I/O processing
29 / 36
CS34
Hardware
Programmed I/O
After I/O starts, control returns to user program only on I/O
completion
I
Programmed I/O
I
CPU waits until I/O completes.
At most one I/O request is outstanding at a time
I
No simultaneous I/O processing
Hardware
2012-12-06
Polled I/O
Polling == Querying the I/O device
Separate I/O into two parts:
I
Initiation
I
Polling
Advantages?
30 / 36
CS34
Hardware
Polled I/O
Polling == Querying the I/O device
Separate I/O into two parts:
Polled I/O
I
Initiation
I
Polling
Advantages?
Hardware
2012-12-06
Interrupt-Driven I/O
Separate I/O into two parts:
I
Initiation
I
Asynchronous notification
31 / 36
CS34
Hardware
Interrupt-Driven I/O
Separate I/O into two parts:
Interrupt-Driven I/O
I
Initiation
I
Asynchronous notification
Hardware
2012-12-06
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
CS34
Hardware
I/O in User-Level Code
User-level code almost always uses “programmed I/O”
(e.g. read and write on a file)
I/O in User-Level Code
Why?
Hardware
2012-12-06
Computer Hardware—CPU with Interrupts
CPU needs another feature. . .
Start
Fetch
Instruction
Execute
Instruction
No
Interrupts
Enabled?
Yes
No
Interrupt?
Yes
Jump to
Handler
Save State
33 / 36
CS34
Hardware
Computer Hardware—CPU with Interrupts
CPU needs another feature. . .
Start
Fetch
Instruction
Execute
Instruction
No
Computer Hardware—CPU with Interrupts
Interrupts
Enabled?
Yes
No
Interrupt?
Yes
Jump to
Handler
Save State
Hardware
2012-12-06
Handling an Interrupt
What needs to happen:
I Save state
I
I
I
All registers
Switch stacks?
Find out what interrupt was. . .
I
I
Polling
Vectored interrupts
34 / 36
CS34
Hardware
Handling an Interrupt
What needs to happen:
I Save state
I
I
Handling an Interrupt
I
All registers
Switch stacks?
Find out what interrupt was. . .
I
I
Polling
Vectored interrupts
Hardware
2012-12-06
Types of Interrupts
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
CS34
Hardware
Types of Interrupts
Various types
Types of Interrupts
I
Software exception (also called a trap)
I
Timer
I
I/O
I
Hardware failure
A modern operating system is interrupt driven
Hardware
2012-12-06
Other Hardware Features
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
CS34
Hardware
Other Hardware Features
We’ve covered interrupts, but hardware has other cool features,
including:
Other Hardware Features
I
Caches
I
Memory management
I
Protection
We’ll come back to hardware as we address these topics.