Download Slide Set 1

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

RSTS/E wikipedia , lookup

Plan 9 from Bell Labs wikipedia , lookup

Copland (operating system) wikipedia , lookup

Spring (operating system) wikipedia , lookup

Unix security wikipedia , lookup

Burroughs MCP wikipedia , lookup

DNIX wikipedia , lookup

Distributed operating system wikipedia , lookup

VS/9 wikipedia , lookup

CP/M wikipedia , lookup

Paging wikipedia , lookup

Process management (computing) wikipedia , lookup

Transcript
operating
systems
OS Concepts
An Introduction
operating
systems
At the end of this module, you should have a
basic understanding of what an operating system
is, what it does, and what the major components
of an operating system are.
operating
systems
Why should I study
operating systems?
operating
systems
Based on a 2007 IT Salary Survey
Application Programmers
Average Salary
Average Bonus
$71,020
$ 3,410
System Programmers
$79,300
$ 3,940
operating
systems
Based on a 2007 IT Salary Survey
Application Programmers
System
Mainframe
Unix/Linux
Windows
$74,100
$76,100
$71,000
System Programmers
$80,840
$84,100
$79,300
operating
systems
Even as an application programmer, most
real commercial applications will require
that you
Understand OS design issues and tradeoffs
Performance
Function
Space
Be able to exploit OS capabilities
Multiple Processes
Threads
Synchronization
Communication
What Is An Operating
System
operating
systems
User
User
User
System and Application Programs
Language Libraries and System Calls
Operating System Kernel
CPU
API
personal computer
mainframe system
Music players
cell phones
game controllers
This program has no sense of
sharing the system’s resources
with other programs. It sees an
Abstract Machine that has all of
the resources that it needs.
Executing
Program
Operating System
Hardware
Device
Device
Device
The Abstract Machine
Modern computing systems are multi-user, multi-program
systems. The fundamental task of an operating system
in this environment is to give each running program a
logical, abstract machine that contains all of the
resources that it needs to do its job.
Execution
Context
Input/Output devices
Memory
CPU
General purpose registers
Status registers
Stack
app
app
Computer System
Organization
app
cpu
memory
system bus
disk
controller
device
controller
printer
device
controller
keyboard
...
Computer System
Operation
cpu
cpu and devices
work concurrently
memory
system bus
disk
controller
device
controller
printer
device
controller
keyboard
...
Computer System
Operation
cpu
memory
each device controller is in
charge of a particular device
type
system bus
disk
controller
device
controller
printer
device
controller
keyboard
...
Computer System
Operation
cpu
memory
system bus
Each device controller
has a local buffer
disk
controller
device
controller
printer
device
controller
keyboard
...
Computer System
Operation
cpu
memory
device controllers send interrupts
to the cpu to tell it that they have
finished an operation the cpu told
them to do
system bus
disk
controller
device
controller
printer
device
controller
keyboard
...
Interrupts
An interrupt causes control to branch to an interrupt
service routine through an interrupt vector.
The address of the interrupted instruction is saved.
Incoming interrupts are disabled while an interrupt
is being processed.
A trap is a software generated interrupt.
An operating system is interrupt driven.
I/O Processing
Synchronous I/O
1. A process starts an I/O operation
2. The requesting process waits
until the I/O completes
requesting process
wait
device driver
interrupt handler
hardware
data
I/O Processing
Asynchronous I/O
1. A process starts an I/O operation
2. An acknowledgement is returned
3. The process continues execution
4. The device interrupts the process
when the I/O is complete
requesting process
device driver
interrupt handler
hardware
data
Processes
A process is defined as a program in execution.
It includes
* The program itself (program segment)
* The program’s data (data segment, stack, heap)
* Open files
* The execution context
For efficiency, modern operating systems allow
many processes to be running concurrently.
When one process has to wait for something,
typically for an I/O operation to complete, the
operating systems schedules another process
to run.
Many programs can be in memory at the same
time. The operating system gives each process
a slice of time in which to run.
Threads
A thread, or thread of execution, is the set of instructions
being executed in a process.
In a single thread system each process has exactly
one execution engine (the logical machine).
In a multi-thread environment, a process may have many
execution engines, one for each thread. Thus, each thread has it’s
own runtime stack, registers, and state information, but they all
share the same address space in memory (program and data),
and the same files.
In new multi-core machines, each logical engine may run on a
real engine.
Resources
All of the components required for a program to do it’s
job are called resources.
* memory
* cpu time
* devices
* files
* network connection
When a process needs to use a resource, it must ask
the operating system for the resource before using it.
Once a process asks for a resource, it suspends operation
and waits until the resource is available.
Responsibilities of the OS
1. Create an abstract machine environment for each
running process.
2. Manage the use of the physical components in
the system, according to the policies of the system’s
administrator or the system designer.
* Device management
* Process and thread management
* Memory Management
* File Management
Device Management
The OS manages the allocation, isolation, and sharing
of devices.
* Terminals
* Disk Drives
* Printers
* Networks
* Keyboard
* etc
Device Drivers
Application Programming Interface
Device Independent Part
Device Driver Interface
Vendor
Specific
Part
Vendor
Specific
Part
Vendor
Specific
Part
Process & Resource
Management
Schedules the processor so that each thread/process receives
an equitable fraction of the available time, and maintains
the execution context for each thread (stack, registers, etc)
Allocates resources to processes when they are requested
and keeps track of resources when a thread is finished with
them. Isolates access to resources or allows sharing of
resources as required.
Memory Management
Maintains a unique address space in memory for each
process.
Works with the file and/or device managers to provide
virtual memory (address space is larger than physical
memory).
File Management
Works with the device managers to give applications
A logical view of storage (byte stream, indexed data,
text files, etc), and manage the flow of information
between the actual storage device and the program.
Design Issues
Performance: The OS must be as efficient as possible,
maximizing the use of machine resources by applications.
There is some overhead involved in providing OS services.
If the overhead gets too large, it negates the value of
the service.
Exclusive Use of Resources: Each process must have the
ability to have exclusive use of the system resources
that it uses. A process must not be able to use a resource
unless the OS has given it permission. Sharing of resources
should also be allowed.
* Protection Mechanisms
* Security Policies
Processor Modes
Modern computing hardware provides multiple modes of
operation:
• User Mode
- Cannot execute all machine instructions (e.g. I/O)
- Can only access memory allocated to the process
• Privileged Mode
- Executes any instruction in the repertoire
- Can access protected memory
- Only executes trusted software (The OS kernel)
Trap Instructions
User Space
...
fork( );
...
User
Process
Kernel
trap table
fork( )
{
…
trap SYS_FORK( )
...
}
Expensive!
Library
Code
SYS_FORK
sys_fork( )
{
/* system function */
...
return;
}
OS Organization
Monolithic Kernels
* All OS function resides in the kernel
* Fast
* difficult to maintain
MicroKernels
* The trusted OS software is as small as possible
- only the essential OS functions
* All other code is implemented in user space
* Performance the major issue – many kernel calls required
The first king is very reclusive and sits in a small castle with high
walls and a few top advisors. The king tells the advisors what to do
and they go outside of the small (but well defended) castle and issue
orders to the knights, merchants and common-folk. The king never
leaves his castle and since only his most trusted advisors are allowed
in the king is very safe from attack. However, because each advisor
has to pass through several guard points it can sometimes take a
little while before the king’s orders can go out or news can come in.
The second king is much different. He doesn’t really live in a castle so
much as it is a large mansion with beautiful grounds. Strongly defended
walls encompass the entire city instead of just the castle. This makes
the king and the populace very secure from outside attacks. And since
this king is very friendly he goes throughout his city meeting and talking
with all of his subjects. Any command he, or his many trusted aides,
give are instantly obeyed. This makes his city very efficient. However,
should any enemy agents manage to penetrate the outer walls, then
they can quite easily assassinate the beloved king. In which case
order breaks down and the entire city riots.
The Unix Kernel
Libraries
Utilities
Apps
Shell
OS System Call Interface
Device Driver
Driver Interface
Device Driver
Trap Table
Monolithic Kernel Module
• Process Mgt
• Memory Mgt
• File Mgt
• Device Mgt