資工碩一 林昱宏 [email protected]. ch 1 main purposes of operating system...

46
資資資 資資資 [email protected]

Post on 22-Dec-2015

243 views

Category:

Documents


1 download

TRANSCRIPT

  • Slide 1
  • [email protected]
  • Slide 2
  • CH 1 Main purposes of operating system Multiprogramming Time-Sharing Systems Parallel Systems Symmetric multiprocessing (SMP) Asymmetric multiprocessing (ASMP) Real-Time Systems Distributed Systems
  • Slide 3
  • Main purposes of operating system user hardware user user program process
  • Slide 4
  • Multiprogramming Def CPU process CPU utilization CPU idle CPU scheduling process wait for I/O complete OS CPU process Multiprogramming v.s. Multiprocessor
  • Slide 5
  • Time-Sharing Systems Def Multiprogramming RR (Round-Robin) CPU scheduling user user interactive user response time user memory space I/O device
  • Slide 6
  • Parallel Systems Multiprocessor systems tightly coupled systems CPU memory bus I/O device OS clock processor share memory parallel computing process thread processor throughput Symmetric multiprocessing (SMP) Asymmetric multiprocessing (ASMP)
  • Slide 7
  • Real-time System Def Hard real-time system RAM ROM secondary storage virtual memory Soft real-time system process priority scheduling aging UNIX
  • Slide 8
  • Distributed System Def CPU CPU memory space I/O device CPU clock rate OS CPU ( ) bus
  • Slide 9
  • CH2 Interrupt I/O Interrupts Direct Memory Access (DMA) Storage-device Hierarchy Hardware Resource Protection Dual-Mode Operation I/O Protection Memory Protection CPU Protection
  • Slide 10
  • Interrupt Interrupt OS process interrupt ID interrupt vector Interrupt Service Routine (ISR) ISR process
  • Slide 11
  • I/O Interrupts User process I/O request user process Synchronous I/O I/O Asynchronous I/O I/O
  • Slide 12
  • DMA ( Direct Memory Access ) Def DMA controller I/O device Memory CPU CPU utilization Disk block data block interrupt byte
  • Slide 13
  • Storage-device Hierarchy
  • Slide 14
  • Dual-Mode Operation 2 user mode monitor mode User mode user program privileged instruction Trap OS process Monitor mode OS system process user program mode privileged instruction mode bit user mode monitor mode monitor mode privileged instruction
  • Slide 15
  • I/O Protection user program I/O device service user program OS I/O request OS I/O I/O result user program I/O user OS I/O
  • Slide 16
  • Memory Protection user program OS memory interrupt vector ISR base limit Register process B B+L memory protection B L Register privileged instruction
  • Slide 17
  • CPU Protection user program CPU OS CPU time (time slice) timer counter counter 0 time-out OS OS process CPU / timer
  • Slide 18
  • CH3 System Components System Calls Virtual Machine
  • Slide 19
  • System Components Process Management Main-Memory Management File Management I/O-System Management Secondary-Storage Management Networking Protection System Command-Interpreter System
  • Slide 20
  • System Calls (1/3) Def user program OS user program OS system call OS OS service routine
  • Slide 21
  • System Calls (2/3) System call OS register memory block ( table) register table system stack push stack system call pop
  • Slide 22
  • System Calls (3/3) System call Process control File manipulation Device manipulation Information maintenance Communication
  • Slide 23
  • Virtual Machine Def copy hardware OS OS JVM
  • Slide 24
  • Mechanism v.s. Policy Mechanisms determine how to do something Policies decide what will be done.
  • Slide 25
  • CH4 Diagram of Process State Process Control Block (PCB) Schedulers Long-term scheduler Short-term scheduler Context Switch
  • Slide 26
  • Diagram of Process State
  • Slide 27
  • Process Control Block (PCB) OS process management process PCB
  • Slide 28
  • Schedulers Long-term scheduler (job scheduler) multiprogramming degree I/O bound CPU bound job Short-term scheduler (CPU scheduler) process process Medium-term Scheduler process (Swapping) process
  • Slide 29
  • Context Switch CPU process process OS process ( program counter CPU register PCB ) process context switch
  • Slide 30
  • Communication Direct Communication send (P, message) receive(Q, message) Indirect Communication mailbox
  • Slide 31
  • CH5 Thread Thread Benefits Thread V.S Process User and Kernel Threads Multithreading Models Many-to-One One-to-One Many-to-Many
  • Slide 32
  • Thread Light weight process (LWP) process thread Code section Data section OS resource
  • Slide 33
  • Thread Benefit Responsiveness Resource Sharing Economy Utilization of Multiprocessor Architectures
  • Slide 34
  • Thread V.S Process ProcessThread Heavyweight processLightweight process process address space process thread code section data section os resource (create scheduling context switching) Single-Threaded ModelMulti-Threaded Model ( process thread process block) Multiprocessor
  • Slide 35
  • User and Kernel Threads User threads Def implemented by a thread library at user level. fast to create and manage if the kernel is single threaded, then.. Kernel threads Def Supported directly by OS slower to create and manage if a thread performs a blocking system call, the kernel can schedule another thread in the application for execution.
  • Slide 36
  • Multithreading Models Many-to-One Model thread , One-to-One Model Many-to-Many Model
  • Slide 37
  • CH6 Scheduling Criteria Scheduling Algorithms
  • Slide 38
  • Scheduling Criteria CPU utilization CPU Throughput Turnaround time process Waiting time process ready Queue Response time user request
  • Slide 39
  • Scheduling Algorithms First-Come, First-Served (FCFS) Scheduling Shortest-Job-First (SJR) Scheduling Non-Preemptive Preemptive Priority Scheduling Round Robin (RR) Multilevel Queue Multilevel Feedback Queue
  • Slide 40
  • Scheduling Algorithms First-Come, First-Served (FCFS) Scheduling Def arrival time process CPU Avg. waiting time turnaround time Convoy effect fair no starvation non-preemptive
  • Slide 41
  • Scheduling Algorithms Shortest-Job-First Scheduling Def process CPU burst time CPU Avg. waiting time turnaround time Unfair starvation non-preemptive
  • Slide 42
  • Scheduling Algorithms Priority Scheduling Def process CPU Unfair Starvation
  • Slide 43
  • Scheduling Algorithms Round-Robin Scheduling Def Time-sharing system OS CPU time quantum process CPU quantum CPU Fair No starvation Preemptive Time quantum too large -> FCFS
  • Slide 44
  • Scheduling Algorithms Multilevel Queue Scheduling Def ready Queue ready Queue Queue scheduling algo. Process Queue Unfair Starvation Preemptive
  • Slide 45
  • Scheduling Algorithms Multilevel Feedback-Queue Scheduling Def process Queue aging process Queue Unfair No Starvation Preemptive
  • Slide 46
  • Starvatio n preemptive FIFO XX Convoy effect SJFX X SRJFX PriorityX /X RR X Time sharing Multilevel Queue X P queue Multilevel freeback Queue X P queue (aging)