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) output CPU data MEM
What is an Operating System? (system view) output CPU data MEM prog1 prog2 prog3 prog4 Control program Resource allocator
Computer-system operation (The OS initialization phase) ROM 1 2 RAM 3
Computer-System Organization (after booting) applications Sys. call signal OS cmd Hardware polling interrupt
OS operations I/O devices and the CPU execute concurrently AP1 applications I/O devices and the CPU execute concurrently AP1 AP2 AP2 Sys. call signal OS 1 cmd 4 3 interrupt buffer 2 controller
Common Functions of Interrupts (interrupt vector table, IVT) mem Interrupt transfers control to the interrupt service routine Disable all incoming interrupts (???) Save the CPU status of the interrupted program IDTR 1 2’ ISR 2” IDTR: interrupt descriptor table register
Common Functions of Interrupts applications Software interrupt Sys. call signal OS kernel cmd Hardware polling interrupt Basically, an operating system is interrupt driven. Dual-Mode operation: kernel mode + user mode
Interrupt Handling Save the CPU status (including the CPU status register, program counter and some other registers) Interrupt handling depends on the type of interrupt polling vectored interrupt system vectored interrupt system + polling 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
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
Storage-Device Hierarchy compiler 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 (OS)
Cache (Coherency & consistency) L1 $ L1 $ L2 $ L2 $ bus
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 I/O ready CPU ready CPU I/O time
Timesharing CPU ready CPU I/O CPU ready CPU ready CPU I/O time
Operating-System Operations applications AP1 AP2 AP2 Sys. call int_ret OS 1 cmd 4 3 interrupt buffer 2 controller
Dual-mode operation AP1 applications AP2 AP2 User mode Sys. call Int_ret Kernel mode OS 1 cmd 4 3 interrupt buffer 2 controller
Dual-mode operation applications trap AP2 User mode Kernel mode OS Syscall_handler ISR CPU Mode=kernel_mode Push PC Save machine status Jump_to ISR Exception := Trap := Software interrupt
Dual-mode operation AP1 applications AP2 AP2 User mode Sys. call Int_ret Kernel mode OS Syscall_handler 1 cmd 4 3 interrupt buffer 2 controller
Dual-mode operation applications trap AP2 AP2 User mode Kernel mode OS Syscall_handler ISR CPU restore machine status Mode=user_mode Pop PC
Timer time CPU ready CPU I/O CPU ready CPU ready CPU I/O timer interrupt time timer
OS OS Structure Protec-tion Process manage-ment Memory manage-ment setuid… SELinux OS Protec-tion Process manage-ment Memory manage-ment Storage manage-ment security passwd… fork… open & close… malloc..
Computing Environments (symmetric multiprocessor, SMP) CPU 0 CPU 1 CPU 2 bus
Computing Environments (chip multiprocessor, CMP) CPU Core 0 Core 1 L1 $ L1 $ L2 $ bus
Computing Environments (simultaneously multithreading, SMT) CPU Core Logical processor 0 Logical processor 1 L1 $ L2 $ bus
Computing Environments (CMP+SMT) CPU Core 0 Core 1 LP0 LP1 LP0 LP1 L1 $ L1 $ L2 $ bus
Computing Environments (symmetric multiprocessor, SMP) (UMA) CPU 0 CMP+SMT CPU 1 CMP+SMT CPU 2 CMP+SMT bus
Computing Environments (symmetric multiprocessor, SMP) (NUMA) CPU 0 CMP+SMT CPU 1 CMP+SMT CPU 2 CMP+SMT bus
Embedded systems & web computing internet WEB apps
參考資料 Silberschatz, Galvin and Gagne, “Operating system Principles,” 8th ed Wikipedia, http://www.wikipedia.org/