Download interrupt

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

Copland (operating system) wikipedia , lookup

Spring (operating system) wikipedia , lookup

Unix security wikipedia , lookup

Distributed operating system wikipedia , lookup

CP/M wikipedia , lookup

DNIX wikipedia , lookup

RSTS/E wikipedia , lookup

VS/9 wikipedia , lookup

Process management (computing) wikipedia , lookup

Transcript
Chapter 1: Introduction
Chapter 1: Introduction
• What Operating
Systems Do
• Computer-System
Organization
• Operating-System
Structure
• Operating-System
functionalities
•
•
•
•
Process Management
Memory Management
Storage Management
Protection and Security
• Computing
Environments
Objectives
• To understand the computer system
organization
• To understand the major operating system
components
What is an Operating System?
(user view)
?
What is an Operating System?
(user view)
#&*…%$
#@
OS
For ease of use
What is an Operating System?
(system view)
CPU
data
output
MEM
What is an Operating System?
(system view)
CPU
data
output
MEM
prog1
Control program
prog3
prog2
prog4
Resource
allocator
Computer-system operation
(The OS initialization phase)
ROM
1
2
RAM
3
Computer-System Organization
(after booting)
signal
Sys. call
applications
OS
cmd
polling
interrupt
Hardware
OS operations
I/O devices
and the CPU
execute
concurrently
AP1
applications
AP2
AP2
return
Sys. call
OS
1
cmd
4
interrupt
3
2
buffer
controller
Common Functions of Interrupts
(interrupt vector table, IVT)
mem
1. Interrupt transfers control to the
interrupt service routine
2. Disable all incoming interrupts (why?)
3. Save the CPU status of the interrupted
program
1
IDTR
2’
ISR
2”
IDTR: interrupt descriptor table register
Common Functions of Interrupts
applications
signal
Sys. call
Software
interrupt
OS kernel
cmd
polling
interrupt
Hardware
Basically, an operating system is interrupt driven.
Dual-Mode operation: kernel mode + user mode
Interrupt Handling
1. Save the CPU status (including the CPU status
register, program counter and some other
registers)
2. Interrupt handling depends on the type of
interrupt
– polling
– vectored interrupt system
– vectored interrupt system + polling
3. Execute the interrupt service routine.
Direct Memory Access Structure
(DMA)
bus
Direct Memory Access Structure
(DMA)
cache
bus
Two I/O Methods
• After I/O starts, control returns to user
program only upon I/O completion.
– Synchronous I/O
– Cons:???
– Pros:???
• After I/O starts, control returns to user
program without waiting for I/O completion.
– Asynchronous I/O
– Cons:???
– Pros:???
Two I/O Methods
Synchronous
Asynchronous
Storage Hierarchy
• Storage systems organized in hierarchy.
– Speed
– Cost
– Volatility
• Caching – a temporary storage area where frequently
accessed data can be stored for rapid access.
– Register: main memory
– Cache memory: main memory
– Main memory: disk
compiler
Storage-Device Hierarchy
OS
only large storage
media that the CPU can
access directly.
extension of main
memory that provides
large nonvolatile
storage capacity.
Performance of Various Levels of
Storage
Cache
(Coherency & consistency)
a=2
a=3
L1 $
L1 $
a=0
bus
a=0
for (i=0..3) {
a=a+1;
}
a=0
Cache
(Coherency & consistency)
coherency
a=2
a=3
L1 $
L1 $
a=0
consistency
bus
a=0
for (i=0..3) {
a=a+1;
}
a=0
Operating System Structure
• Multiprogramming needed for efficiency
Server
When CPU has to wait (for I/O for example), OS
switches to another program
• Timesharing (multitasking) creates interactive
computing
Personal computer
+ programs exhaust their time slice
Multiprogramming
CPU
ready
I/O
ready
CPU
CPU
I/O
time
Time sharing
CPU
ready
CPU
ready
CPU
ready
I/O
CPU
CPU
I/O
time
Operating-System Operations
applications
AP2
Sys. call
OS
interrupt
buffer
controller
Dual-mode operation
(system call)
applications
Kernel
mode
AP2
Sys. call
User
mode
OS
Dual-mode operation
applications
User
mode
AP2
trap
Kernel
mode
ISR
Syscall_handler
OS
CPU
1. Mode=kernel_mode
Push PC
1. Save machine status
2. Jump_to ISR
Exception
:= Trap
:= Software interrupt
Dual-mode operation
AP1
applications
Kernel
mode
AP2
Sys. call
User
mode
Syscall_handler
OS
1
cmd
4
interrupt
3
2
buffer
controller
Dual-mode operation
applications
User
mode
AP2
trap
AP2
Kernel
mode
ISR
Syscall_handler
OS
CPU
1. restore machine status
2. Mode=user_mode
Pop PC
Kernel mode & user mode
CPU
– Kernel mode
– User mode
• Memory
– Kernel space
– User space
• INT 0x80
– System call
Root & normal user
• User
– Root
– Normal user
• File system
– Owner: root
– Owner: normal user
• sudo
Timer
CPU
ready
CPU
ready
CPU
ready
I/O
CPU
CPU
I/O
interrupt
timer
time
OS Structure
setuid…
SELinux
Protection
passwd
…
security
OS
fork…
Process
management
open &
close…
malloc..
Storage
management
Memory
management
Computing Environments
(symmetric multiprocessor, SMP)
CPU 0
CPU 1
bus
CPU 2
Computing Environments
(chip multiprocessor, CMP)
CPU
Core 0
Core 1
L1 $
L1 $
L2 $
bus
Computing Environments
(simultaneously multithreading, SMT)
CPU
Logical
processor 0
Logical
processor 1
Core
L1 $
L2 $
bus
Computing Environments
(CMP+SMT)
CPU
LP0
LP1
LP0
LP1
Core 0
Core 1
L1 $
L1 $
L2 $
bus
Computing Environments
(symmetric multiprocessor, SMP)
(UMA)
CPU 0
CPU 1
CPU 2
CMP+SMT
CMP+SMT
CMP+SMT
bus
Computing Environments
(symmetric multiprocessor, SMP)
(NUMA)
CPU 0
CPU 1
CPU 2
CMP+SMT
CMP+SMT
CMP+SMT
bus
Embedded systems &
web computing
internet
WEB apps
參考資料
• Silberschatz, Galvin and Gagne, “Operating
system Principles,” 8th ed
• Wikipedia, http://www.wikipedia.org/