Interrupt Handler Μ−Kernel – Harder to Let System Services Share Resources Dispatcher • Why?
Total Page:16
File Type:pdf, Size:1020Kb
Operating System “Structures” Otto J. Anshus 1 Demo •POS P5 (today) •MorbOS (tomorrow) 2 “Structures” (Architectures) • Layered • OS as Resource Manager & Protector • Monolithic – HW (CPU, memory, ...) – SW (file systems, network stack, ...) • Micro kernel – Isolate users and processes from each other • OS as illusionist (a.k.a. virtual machine) • Virtual Machine – Abstractions – Easy use of abstractions • Unix: read/write data from/to sockets instead of having to • Hybrids handle TCP/IP packets in user level code 3 Layered • Hiding information at each layer • Develop a layer at a time Level N • Examples . – THE (6 layers, semaphores, Dijkstra 1968) . – MS-DOS (4 layers) Level 2 • Pros – Separation of concerns Level 1 – Elegant (at first sight) • Cons Hardware – Protection boundary crossings – Performance 4 Layered • Hiding information at each layer • Develop a layer at a time Level N • Examples . – THE (6 layers, semaphores, Dijkstra 1968) . – MS-DOS (4 layers) Level 2 • Pros – Separation of concerns Level 1 – Elegant (at first sight) • Cons Hardware – Protection boundary crossings – Performance Each layer can end up having to support multiple events happening (a.k.a. complications (and we don’t like complications)) 4 Layered • Hiding information at each layer • Develop a layer at a time Level N • Examples . B – THE (6 layers, semaphores, Dijkstra 1968) . A – MS-DOS (4 layers) Level 2 D • Pros – Separation of concerns Level 1 – Elegant (at first sight) • Cons Hardware – Protection boundary crossings – Performance Each layer can end up having to support multiple events happening (a.k.a. complications (and we don’t like complications)) 4 Monolithic • All of OS is in a fat Kernel User User • Examples program program – Classic Unix (Linux, BSD Unix, ...) return – Windows NT (hybrid) call – Mach (can be a fat kernel) – MacOS (Mach kernel) • Pro entry – Performance – Shared kernel space Kernel (Does it all) • Cons – Stability: Faulty drivers can crash the system (>75% of a modern OS are drivers). – Flexibility: Low • (However, made flexible with loadable kernel modules (Linux)) – Security • All runs in privileged kernel mode, with direct access to kernel data structures. • Kernel allow module loading (Great for a rootkit.) 5 Microkernel • Micro-kernel has just a few abstractions and functionalities – Abstractions • Process abstraction, address space, interrupts, IPC User OS – Syscall & very few services process Services • OS Services are implemented as user level processes return • Micro-kernel gets services on behalf of users by messaging call message with the service processes passing • Old – Nucleus, Taos, Mach (as a micro kernel, drivers still in entry kernel), • Newer µ−kernel – Minix (Andy Tanenbaum, VU) – Singularity (MS Research) Mach: The mother of all microkernels, 1985-1994. Rick – EROS/CoyotOS (Johns Hopkins University) Rashid (CMU, Microsoft Research), Avie Tevanian (ex-Apple CTO), Brian Bershad (U of Washington, Google) – L4 microkernel family (originally Jochen Liedtke when at IBM/GMD/Karlsruhe) Single Server Unix (BSD4.3) MkLinux (OSF) Brinch-Hansen: “The Nucleus of a Multiprogramming IBM Workplace OS 6 System..”, 1970. Recommended readings. NeXT OS -> Mac OS X Microkernel Pros et Cons • Pros – Smaller kernel User OS • Less bugs • Easier to tune/optimize process Services • Easier to port to a new platform return – Extend or customize call – Do verification – Trust (TCB) – Fault isolation entry • Cons Interrupt handler µ−kernel – Harder to let system services share resources Dispatcher • Why? 7 Microkernel Pros et Cons • Pros – Smaller kernel User OS • Less bugs • Easier to tune/optimize process Services • Easier to port to a new platform return – Extend or customize call – Do verification – Trust (TCB) – Fault isolation entry • Cons Interrupt handler µ−kernel – Harder to let system services share resources Dispatcher • Why? – Performance • Naive case: Multiple protection boundary crossings – How many? 7 Microkernel Pros et Cons • Pros – Smaller kernel User OS • Less bugs • Easier to tune/optimize process Services • Easier to port to a new platform return – Extend or customize call – Do verification – Trust (TCB) – Fault isolation entry • Cons Interrupt handler µ−kernel – Harder to let system services share resources Dispatcher • Why? – Performance • Naive case: Multiple protection boundary crossings – How many? 7 Microkernel Pros et Cons • Pros – Smaller kernel User OS • Less bugs • Easier to tune/optimize process Services • Easier to port to a new platform return – Extend or customize call – Do verification – Trust (TCB) – Fault isolation entry • Cons Interrupt handler µ−kernel – Harder to let system services share resources Dispatcher • Why? – Performance • Naive case: Multiple protection boundary crossings – How many? 7 Microkernel Pros et Cons • Pros – Smaller kernel User OS • Less bugs • Easier to tune/optimize process Services • Easier to port to a new platform return – Extend or customize call – Do verification – Trust (TCB) – Fault isolation entry • Cons Interrupt handler µ−kernel – Harder to let system services share resources Dispatcher • Why? – Performance • Naive case: Multiple protection boundary crossings – How many? 7 Microkernel Pros et Cons • Pros – Smaller kernel User OS • Less bugs • Easier to tune/optimize process Services • Easier to port to a new platform return – Extend or customize call – Do verification – Trust (TCB) – Fault isolation entry • Cons Interrupt handler µ−kernel – Harder to let system services share resources Dispatcher • Why? – Performance • Naive case: Multiple protection boundary crossings – How many? 7 User User process process Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; Get parameters and Start requested service Service Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware Interrupts from network, disk, keyboard,… User User process process Call Service(…); int 80h Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; Get parameters and Start requested service Service Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware Interrupts from network, disk, keyboard,… User User process process Call Service(…); int 80h Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; Get parameters and Start requested service Service Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware Interrupts from network, disk, keyboard,… User User process process Call Service(…); int 80h Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; Get parameters and Start requested service Service Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware Interrupts from network, disk, keyboard,… User User process process Call Service(…); int 80h Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; Get parameters and Start requested service Service Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware Interrupts from network, disk, keyboard,… User User process process Call Service(…); int 80h Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; Get parameters and Start requested service Service Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware Interrupts from network, disk, keyboard,… User User process process Call Service(…); int 80h Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; Get parameters and Start requested service Service let Service run || OSK continue Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware Interrupts from network, disk, keyboard,… User User process process Call Service(…); int 80h Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; Get parameters and Start requested service Service let Service run || OSK continue Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware ALTERNATIVELY: Sometimes later int 80h (when Service finishes) {K||service||processes} int by HW Interrupts from network, disk, keyboard,… User User process process Call Service(…); int 80h Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; make UL caller of Service Ready again AND write results to UL memory Get parameters and Start requested service Service let Service run || OSK continue Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware ALTERNATIVELY: Sometimes later int 80h (when Service finishes) {K||service||processes} int by HW Interrupts from network, disk, keyboard,… User User Service process process Service Call Service(…); Service Service int 80h Operating System Kernel INTERRUPT HANDLER: Analyze interrupt; make UL caller of Service Ready again AND write results to UL memory Get parameters and Start requested service Service let Service run || OSK continue Service int 8016 Service SCHEDULER: Select next process to resume DISPATCHER: restore context and iret Interrupt Hardware ALTERNATIVELY: Sometimes later int 80h (when Service finishes) {K||service||processes} int by HW Interrupts from network, disk, keyboard,… User User Service process process Service Call Service(…); Service Service int 80h Operating System