Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Plan 9 from Bell Labs wikipedia , lookup
Copland (operating system) wikipedia , lookup
Burroughs MCP wikipedia , lookup
Unix security wikipedia , lookup
Spring (operating system) wikipedia , lookup
Security-focused operating system wikipedia , lookup
Linux kernel wikipedia , lookup
Distributed operating system wikipedia , lookup
Kernel (operating system) wikipedia , lookup
Witawas Srisa-an CSCE 351: Operating System Kernels Lecture 6: Kernel Structures and Threading Summary 1. Computer system overview (Chapter 1) 2. Basic of virtual memory; i.e. segmentation and paging (Chapter 7 and part of 8) 3. Process (Chapter 3) 4. Mutual Exclusion and Synchronization (Chapter 5 section 1-4) • Conditions for race avoidance. • Strict alternation. • Semaphores. • Producers and Consumers problem. • Hardware support for mutual exclusion. • Monitors. User Mode vs. Kernel Mode 1. Kernel architectures • Monolithic kernel (Unix, Windows 9X, MS-DOS) • Layered kernel (THE, MULTICS) (see Figure 4.10) • Microkernel (Symbian, Singularity, Minix) • Hybrid Kernel (Windows NT kernel) 2. Transition from user mode to kernel mode (see Figure 3.17) • System calls. • Exceptions. • Interrupts. Threads 1. Processes • Resource ownership. • Scheduling/execution. 2. Thread: An execution path within a process (see Figure 4.1) • MS-DOS (single-process/single-thread) (see Figure 4.2). • Early flavor of UNIXs (muti-process/single-thread). • Windows, Solaris (multi-process/multi-thread). 3. Distinguishing between process and thread University of Nebraska-Lincoln Lecture 6 – 1 Computer Science and Engineering Witawas Srisa-an CSCE 351: Operating System Kernels • Process: Unit of resource allocation and protection. • Thread: Execution unit. (a) Execution state. (b) Execution context (PC, stack, per-thread storage for local variable, access to resources). 4. Benefits of Threading • Foreground/background work. • Asynchronous processing. • Speed of execution. • Modular program structure. 5. Thread states (a) Spawn. (b) Block. (c) Unblock. (d) Finish. 6. Synchronization and mutual exclusion (same as process) 7. User-level versus kernel-level threads (see Figure 4.6) • User-level threads: Threads are not recognized by kernel. – – – – – Thread switching requires no kernel intervention. Scheduling policy can be application specific. Portable, threading library provides as utilities. Blocking call in a thread can block all threads in the same processes. Multithreaded application cannot take advantage of multiprocessing. • Kernel-level threads: User-level threads are mapped to kernel threads. – Support scheduling of threads in the same process in multiprocessor environment. – A blocked threads does not cause other threads in the same process to block. – Scheduling is done entirely in the kernel. • Comparing thread management schemes between Solaris and Linux (see Figure 4.15). University of Nebraska-Lincoln Lecture 6 – 2 Computer Science and Engineering Witawas Srisa-an CSCE 351: Operating System Kernels fork Created Preempted not enough memory (swapping system only) enough memory return to user User Running preempt return system call, interrupt reschedule process Ready to Run In Memory swap out swap in Ready to Run Swapped Kernel Running wakeup sleep interrupt, interrupt return wakeup exit Zombie Asleep in Memory swap out Sleep, Swapped Figure 3.17 UNIX Process State Transition Diagram one process one thread one process multiple threads multiple processes one thread per process multiple processes multiple threads per process = instruction trace Figure 4.1 Threads and Processes [ANDE97] University of Nebraska-Lincoln Lecture 6 – 3 Computer Science and Engineering Witawas Srisa-an CSCE 351: Operating System Kernels Single-Threaded Process Model Process Control Block User Stack User Address Space Kernel Stack Multithreaded Process Model Thread Thread Thread Thread Control Block Thread Control Block Thread Control Block Process Control Block User Stack User Stack User Stack User Address Space Kernel Stack Kernel Stack Kernel Stack Figure 4.2 Single Threaded and Multithreaded Process Models Threads Library User Space User Space Kernel Space Kernel Space User Space Threads Library Kernel Space P P P (a) Pure user-level User-level thread (b) Pure kernel-level Kernel-level thread Figure 4.6 University of Nebraska-Lincoln P P (c) Combined Process User-Level and Kernel-Level Threads Lecture 6 – 4 Computer Science and Engineering Witawas Srisa-an CSCE 351: Operating System Kernels User Mode File System User Mode Interprocess Communication Kernel Mode d e v i c e c l i e n t Users p r o c e s s I/O and Device Management Virtual Memory • • • Kernel Mode Primitive Process Management f i l e s e r v e r d r i v e r s p r o c e s s v i r t u a l s e r v e r m e m o r y Microkernel HARDWARE HARDWARE (a) Layered kernel (b) Microkernel Figure 4.10 Kernel Architecture Process 1 Process 2 Process 3 Process 4 L L Process 5 User L L L L L L Threads Library L Kernel P Hardware User-level thread Kernel thread P P L Lightweight Process P P P Processor Figure 4.15 Solaris Multithreaded Architecture Example University of Nebraska-Lincoln Lecture 6 – 5 Computer Science and Engineering