Download Contact Information

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

Spring (operating system) wikipedia , lookup

DNIX wikipedia , lookup

MTS system architecture wikipedia , lookup

Copland (operating system) wikipedia , lookup

Unix security wikipedia , lookup

Distributed operating system wikipedia , lookup

RSTS/E wikipedia , lookup

Process management (computing) wikipedia , lookup

CP/M wikipedia , lookup

VS/9 wikipedia , lookup

Transcript

We will focus on operating system concepts


What does it do? How is it implemented?
Apply to Windows, Linux, Unix, Solaris, Mac OS X.


Will discuss differences between implementations.
Will use programming to enhance our understanding
of basic concepts.
Today’s Topics






High level view of Operating System
Interrupts
Context Switches
Multiprogramming
Timesharing
Protection of system resources.
Components of a Computer System
User
Web Browsing
User
User
Text Editor
Database
User
Compiler
System and application Programs
Operating System
Hardware



System and Application Programs
Operating System
Hardware (CPU, memory, I/O
devices).
Components of a Computer System
App1
App2
Web Browsing
App3
Text Editor
Database
App4
iTunes
System and application Programs
Operating System
Hardware



System and Application Programs
Operating System
Hardware (CPU, memory, I/O
devices)

System programs make our lives easier but are not
part of the Operating System.


Compilers, editors, linkers, loaders, shells…….
Operating System performs two functions:


Allocates, schedules, manages, and protects system
resources.
Provides a convenient interface to system resources.

Don’t want to have to write device driver to store files on disk.
Interrupts

Operating systems are interrupt-driven.

Perform action, such as giving control of the CPU to an
application, then does not regain control of CPU until an
interrupt occurs.

CPU and other devices can run concurrently.



Can start I/O operation and start application executing.
When requested operation completed, device generates
hardware interrupt.
User programs generate interrupts when making
system calls (requesting service from OS)


TRAP instruction.
Generally termed software interrupt.
Interrupts

When an interrupt is generated, the CPU stops what
it is doing and execution is transferred to the
appropriate interrupt handler.

Addresses of interrupt handlers are found in the interrupt
vector.


Table of addresses
Each device (and TRAP) has a particular offset within the table
Interrupt Vector
0
100
1
500
2
800
3
1500
0 I/O Device 1
1 I/O Device 2
2 NIC
3 TRAP
Interrupts


Consider some Joe_Program (nickname is JP or Joe)
executing and a device issues an interrupt.
Need to jump to interrupt handler, but ……
Interrupts



Consider some Joe_Program executing and a device
issues an interrupt.
Need to jump to interrupt handler, but ……
What do we do with Joe?
Interrupts



Consider some Joe_Program executing and a device
issues an interrupt.
Need to jump to interrupt handler, but ……
What do we do with Joe?

What is the minimal information to save to be able to restart
his execution?
Interrupts


Consider some Joe_Program executing and a device
issues an interrupt.
What do we do with Joe?

What is the minimal information to save to be able to restart
his execution?

Address of the next instruction.

What if interrupt processing routine needs to use all
of the CPU registers?

What if interrupt processing routine needs to use all
of the CPU registers?

Better save a copy of the state of all of the registers PJ is
using.

Once interrupt routine completed, how do we get JP
restarted?

Once interrupt routine completed, how do we get JP
restarted?


Restore state of registers
Set the Instruction Pointer to the next instruction JP was
going to execute.

It should appear to JP as if its execution was never interrupted.

Saving and restoring application state is termed a
context switch.
Operating System Structure

A key concept of operating systems is
multiprogramming (or multitasking).


Technique developed because CPU and I/O device time
were very expensive.
Basic idea:


Keep multiple jobs in memory.
When one job blocks on I/O, the CPU immediately
switches to another job.



This keeps CPU and I/O devices fully utilized.
Without multiprogramming, CPU would be idle during I/O
operations.
First developed for batch systems in the 60s.

No interactions between user and programs.
Multiprogramming Batch Systems
Problem: CPU and I/O very expensive.
Solution: Multiplex CPU between multiple jobs.
Time-Sharing Systems–Interactive Computing




Logical extension of multiprogramming.
The CPU is multiplexed among several jobs that are kept
in memory and on disk (the CPU is allocated to a job only
if the job is in memory).
A job swapped in and out of memory to the disk.
Each user is executing a shell program.
 Takes user command and executes it.
 Waits for the next command.
Time-Sharing Systems–Interactive Computing


Goal is to give the illusion that each user has own
machine.
Response time is a priority.
Protection of System Resources




I/O Devices
Memory
CPU
Files
Protection of System Resources

Based on dual-mode execution:



kernel mode and user mode.
Privileged instructions can be issued only in kernel mode.
Mode bit in PSW, checked on every instruction.
User process
executing
Continue Execution
System Call
Mode
Bit=1
Trap, mode bit = 0
Execute System Call
Return. Mode
bit = 1
Protection of I/O Devices


All I/O instructions are privileged instructions.
Only accessed through system calls.
Memory Protection



Must provide memory protection for the interrupt
vector, interrupt service routines, and other
applications address space.
Two registers that determine the range of legal
addresses a program may access:
 Base register – holds the smallest legal physical
memory address.
 Limit register – contains the size of the range
Memory outside the defined range is
protected.
Use of A Base and Limit Register
Hardware Address Protection
CPU (and OS) Protection


Keep user from monopolizing CPU.
Ensure OS regains control of CPU.
CPU Protection

Timer – interrupts computer after specified period to
ensure operating system maintains control.



Timer is decremented every clock tick.
When timer reaches the value 0, an interrupt occurs.
Timer commonly used to implement time sharing.
Privileged Instructions

Load base and limit registers?
Privileged Instructions


Load base and limit registers?
Set the system timer?
Privileged Instructions



Load base and limit registers?
Set the system timer?
Read the system clock?
Privileged Instructions




Set the system timer?
Read the system clock?
Load base and limit registers?
Open a file?
Privileged Instructions





Load base and limit registers?
Set the system timer?
Read the system clock?
Open a file?
Compile a program and create executable?
Privileged Instructions






Load base and limit registers?
Set the system timer?
Read the system clock?
Open a file?
Compile a program and create executable?
Enable/disable interrupts?