threads smp and microkernels
play

Threads, SMP, and Microkernels Chapter 4 Chapter 4 1 Process - PowerPoint PPT Presentation

Threads, SMP, and Microkernels Chapter 4 Chapter 4 1 Process Process Resource ownership - process includes a R hi i l d virtual address space to hold the process image Scheduling/execution- follows an Scheduling/execution-


  1. Threads, SMP, and Microkernels Chapter 4 Chapter 4 1

  2. Process Process • Resource ownership - process includes a R hi i l d virtual address space to hold the process image • Scheduling/execution- follows an • Scheduling/execution- follows an execution path that may be interleaved with other processes ith th • These two characteristics are treated independently by the operating system 2

  3. Process Process • Dispatching is referred to as a thread or Di hi i f d h d lightweight process • Resource of ownership is referred to as a process or task process or task 3

  4. Multithreading Multithreading • Operating system supports multiple O i l i l threads of execution within a single process • MS-DOS supports a single thread • MS-DOS supports a single thread • UNIX supports multiple user processes but only supports one thread per process • Windows, Solaris, Linux, Mach, and Windows, Solaris, Linux, Mach, and OS/2 support multiple threads 4

  5. 5

  6. Process Process • Have a virtual address space which holds H i l dd hi h h ld the process image • Protected access to processors, other processes files and I/O resources processes, files, and I/O resources 6

  7. Thread Thread • An execution state (running, ready, etc.) A i ( i d ) • Saved thread context when not running • Has an execution stack • Some per-thread static storage for local variables • Access to the memory and resources of its process its process – all threads of a process share this 7

  8. 8

  9. Benefits of Threads Benefits of Threads • Takes less time to create a new thread than a T k l ti t t th d th 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 Since threads within the same process share memory and files, they can communicate with each other without invoking the kernel each other without invoking the kernel 9

  10. Uses of Threads in a Single- User Multiprocessing System • Foreground to background work F d b k d k • Asynchronous processing y p g • Speed of execution • Modular program structure 10

  11. Threads Threads • Suspending a process involves S di i l suspending all threads of the process since all threads share the same address space sp ce • Termination of a process, terminates all th threads within the process d ithi th 11

  12. Thread States Thread States • States associated with a change in thread S i d i h h i h d state – Spawn • Spawn another thread Sp – Block – Unblock Unblock – Finish • Deallocate register context and stacks 12

  13. Remote Procedure Call Using 13 Single Thread

  14. 14 Remote Procedure Call Using Threads

  15. 15 Multithreading Multithreading

  16. 16 Adobe PageMaker Adobe PageMaker

  17. User Level Threads User-Level Threads • All thread management is done by the All h d i d b h application • The kernel is not aware of the existence of threads of threads 17

  18. 18 User Level Threads User-Level Threads

  19. 19

  20. Kernel Level Threads Kernel-Level Threads • Windows is an example of this approach Wi d i l f hi h • Kernel maintains context information for the process and the threads • Scheduling is done on a thread basis S h d li i d th d b i 20

  21. 21 Kernel Level Threads Kernel-Level Threads

  22. 22 VAX Running UNIX-Like Operating System

  23. Combined Approaches Combined Approaches • Example is Solaris E l i S l i • Thread creation done in the user space p • Bulk of scheduling and synchronization of threads within application f th d ithi li ti 23

  24. 24 Combined Approaches Combined Approaches

  25. 25 Relationship Between Threads and Processes

  26. Categories of Computer Systems • Single Instruction Single Data (SISD) Si l I i Si l D (SISD) stream – Single processor executes a single instruction stream to operate on data stored p in a single memory • Single Instruction Multiple Data (SIMD) • Single Instruction Multiple Data (SIMD) stream – Each instruction is executed on a different set of data by the different processors 26

  27. Categories of Computer Systems • Multiple Instruction Single Data (MISD) M lti l I t ti Si l D t (MISD) stream – A sequence of data is transmitted to a set of processors, each of which executes a different instruction sequence. Never implemented instruction sequence Never implemented • Multiple Instruction Multiple Data (MIMD) – A set of processors simultaneously execute A f i l l different instruction sequences on different data sets sets 27

  28. 28

  29. Symmetric Multiprocessing Symmetric Multiprocessing • Kernel can execute on any processor K l • Typically each processor does self- yp y p scheduling form the pool of available process or threads process or threads 29

  30. 30

  31. Multiprocessor Operating System Design Considerations • Simultaneous concurrent processes or Si l threads • Scheduling • Synchronization S h i ti • Memory management y g • Reliability and fault tolerance 31

  32. Microkernels Microkernels • Small operating system core • Small operating system core • Contains only essential core operating systems functions functions • Many services traditionally included in the operating system are now external subsystems operating system are now external subsystems – Device drivers – File systems File systems – Virtual memory manager – Windowing system Windowing system – Security services 32

  33. 33

  34. Benefits of a Microkernel Organization • Uniform interface on request made by a • Uniform interface on request made by a process – Don t distinguish between kernel-level and user- Don’t distinguish between kernel level and user level services – All services are provided by means of message p y g passing • Extensibility – Allows the addition of new services • Flexibility – New features added – Existing features can be subtracted 34

  35. Benefits of a Microkernel Organization • Portability P bili – Changes needed to port the system to a new processor is changed in the microkernel - not in the other services • Reliability – Modular design Modular design – Small microkernel can be rigorously tested 35

  36. Benefits of Microkernel Organization • Distributed system support Di ib d – Message are sent without knowing what the target machine is • Object-oriented operating system Object oriented operating system – Components are objects with clearly defined interfaces that can be defined interfaces that can be interconnected to form software 36

  37. Microkernel Design Microkernel Design • Low-level memory management L l l t – Mapping each virtual page to a physical page frame 37

  38. Microkernel Design Microkernel Design • Interprocess communication I i i • I/O and interrupt management p g 38

  39. Windows Processes Windows Processes • Implemented as objects I l d bj • An executable process may contain one p y or more threads • Both processes and thread objects have B th d th d bj t h built-in synchronization capabilities 39

  40. 40

  41. 41 Windows Process Object Windows Process Object

  42. 42 Windows Thread Object Windows Thread Object

  43. Windows 2000 Thread States • Ready R d • Standby • Running • Waiting • Transition Transition • Terminated 43

  44. 44

  45. Solaris Solaris • Process includes the user’s address P i l d h ’ dd space, stack, and process control block • User-level threads • Lightweight processes (LWP) Li ht i ht (LWP) • Kernel threads 45

  46. 46

  47. 47

  48. Solaris Lightweight Data Structure • Identifier Id tifi • Priority • Signal mask • Saved values of user-level registers Saved values of user level registers • Kernel stack • Resource usage and profiling data R d fili d t • Pointer to the corresponding kernel thread • Pointer to the process structure 48

  49. 49

  50. Linux Task Data Structure Linux Task Data Structure • State • State • Scheduling information • Identifiers d ifi • Interprocess communication • Links • Times and timers • File system • Address space Address space • Processor-specific context 50

  51. Linux States of a Process Linux States of a Process • Running R i • Interruptable p • Uninterruptable • Stopped • Zombie Zombie 51

  52. 52

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend