1 / 33

Threads, SMP, and Microkernels

This comprehensive guide explains the concepts of processes, threads, and microkernels in operating systems, covering resource ownership, dispatching, multithreading, single-threaded and multithreaded process models, benefits of threads, user-level and kernel-level threads, combined thread approaches, and the relationship between threads and processes. It also explores the categories of computer systems and parallel processor architectures.

Download Presentation

Threads, SMP, and Microkernels

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Threads, SMP, and Microkernels

  2. Processes • Resource ownership - process is allocated a virtual address space to hold the process image • Dispatched - process is an execution path through one or more programs • execution may be interleaved with other processes • These two characteristics are treated independently by the operating system

  3. Processes • Dispatching is referred to as a thread • Resource of ownership is referred to as a process or task

  4. Multithreading • Operating system supports multiple threads of execution within a single process • MS-DOS supports a single thread • UNIX supports multiple user processes but only supports one thread per process • Windows NT, Solaris, Linux supports multiple threads

  5. Threads and Processes one process one thread one process multiple threads multiple processes one thread per process multiple processes multiple threads per process

  6. Processes • Have a virtual address space which holds the process image • Protected access to processors, other processes, files, and I/O resources

  7. Threads • Has an execution state (running, ready, etc.) • Saves thread context when not running • Has an execution stack • Has some per-thread static storage for local variables • Has access to the memory and resources of its process • all threads of a process share this

  8. Single Threaded and Multithreaded Process Models Multithreaded Process Model Single-Threaded Process Model Thread Thread Thread Thread Control Block Thread Control Block Thread Control Block Process Control Block User Stack Process Control Block User Stack User Stack User Stack User Address Space Kernel Stack User Address Space Kernel Stack Kernel Stack Kernel Stack

  9. Benefits of Threads • Takes less time to create a new thread than a process • Less time to terminate a thread than a process • Less time to switch between two threads within the same process • Since threads within the same process share memory and files, they can communicate with each other without invoking the kernel

  10. Threads • Suspending a process involves suspending all threads of the process since all threads share the same address space • Termination of a process, terminates all threads within the process • Thread operations: spawn, block, unblock, finish (no suspend, only active)

  11. User-Level Threads • All thread management is done by the application, and is fast • The kernel is not aware of the existence of threads • Thread switching does not require kernel mode privileges • Scheduling is application specific

  12. Kernel-Level Threads • Windows NT, Linux and OS/2 are examples of this approach • Kernel maintains context information for the process and the threads • Switching between threads requires the kernel and may be slower than user-level

  13. Combined Approaches for Threads • Example is Solaris • Thread creation done in the user space • Bulk of scheduling and synchronization of threads done in the user space

  14. Relationship Between Threads and Processes Threads:Process Description Example Systems Most UNIX implementations 1:1 Each thread of execution is a unique process with its own address space and resources. A process defines an address space and dynamic resource ownership. Multiple threads may be created and executed within that process. M:1 Windows NT, Solaris, Linux, OS/2, OS/390, MACH

  15. Relationship Between Threads and Processes Threads:Process Description Example Systems 1:M A thread may migrate from one process environment to another. This allows a thread to be easily moved among distinct systems. Ra (Clouds), Emerald TRIX M:M Combines attributes of M:1 and 1:M cases

  16. Categories of Computer Systems • Single Instruction Single Data (SISD) • single processor executes a single instruction stream to operate on data stored in a single memory • Single Instruction Multiple Data (SIMD) • one instruction is executed on a different set of data by the different processors

  17. Categories of Computer Systems • Multiple Instruction Single Data (MISD) • a sequence of data is transmitted to a set of processors, each of which executes a different instruction sequence. Never implemented • Multiple Instruction Multiple Data (MIMD) • a set of processors simultaneously execute different instruction sequences on different data sets

  18. Parallel Processor Architecture MIMD Distributed memory (self-contained computers) Shared memory multiprocessor Clusters Symmetric multiprocessors (SMP) Master/Slave

  19. Symmetric Multiprocessing • Kernel can execute on any processor • Typically each processor does self-scheduling from the pool of available process or threads • portions of the kernel can execute in parallel in different processors

  20. Symmetric Multiprocessor Organization Processor Processor . . . Processor Cache Cache Cache Main Memory I/O Subsystem

  21. Multiprocessor OS requirements • Must provide functionality of a multiprogramming OS plus additional features to support multiple processors • Simultaneous concurrent processes or threads: kernel routines need to be reentrant • Scheduling done by any processor, can create conflicts. • Synchronization through locks is required. • Memory management needs to be coordinated in the different processors • Much more complex than just multiprogramming OS.

  22. Microkernel • Small operating system core • Contains only essential operating systems functions • Many services traditionally included in the operating system are now external subsystems • device drivers • file systems • virtual memory manager • windowing system and security services

  23. Benefits of a Microkernel Organization • Uniform interface on request made by a process • all services are provided by means of message passing • Extensibility • allows the addition of new services • Flexibility • existing features can be subtracted

  24. Benefits of a Microkernel Organization • Portability • changes needed to port the system to a new processor is changed in the microkernel - not in the other services • Reliability • modular design • small microkernel can be rigorously tested

  25. Benefits of Microkernel Organization • Distributed system support • message are sent without knowing what the target machine is • Object-oriented operating system • components are objects with clearly defined interfaces that can be interconnected to form software

  26. Microkernel Design • Primitive memory management • mapping each virtual page to a physical page frame • Inter-process communication • I/O and interrupt management

  27. Windows NT Processes • Implemented as objects • An executable process may contain one or more threads • Both process and thread objects have built-in synchronization capabilities

  28. Process ID Security Descriptor Base priority Default processor affinity Quota limits Execution time I/O counters VM operation counters Exception/debugging ports Exit status Windows NT Process Object Attributes

  29. Thread ID Thread context Dynamic priority Base priority Thread processor affinity Thread execution time Alert status Suspension count Impersonation token Termination port Thread exit status Windows NT Thread Object Attributes

  30. NT Thread Status Runnable Standby Pick to Run Switch Preempted Ready Running Unblock/Resume Resource Available Resource Available Terminate Block/ Suspend Transition Waiting Terminated Unblock Resource Not Available Not Runnable

  31. Solaris • Process includes the user’s address space, stack, and process control block • User-level threads • Lightweight processes • Kernel threads

  32. Solaris User Level Threads Stop Runnable Wakeup Continue Preempt Stop Stopped Sleeping Dispatch Stop Sleep Active

  33. Solaris Lightweight Processes Timeslice or Preempt Running Stop Wakeup Dispatch Runnable Stopped Blocking System Call Continue Wakeup Stop Active

More Related