1 / 23

Thread

Thread. By Group III Kathryn Bean and Wafa’ Jaffal. Topics Covered. Process vs. Thread Multithreading Benefits of Threads Thread States Different Thread Types Mapping between Processes and Threads Threading Issues Conclusion. Process vs. Thread, Process:. Related to resource ownership

ura
Télécharger la présentation

Thread

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. Thread By Group III Kathryn Bean and Wafa’ Jaffal

  2. Topics Covered • Process vs. Thread • Multithreading • Benefits of Threads • Thread States • Different Thread Types • Mapping between Processes and Threads • Threading Issues • Conclusion

  3. Process vs. Thread, Process: • Related to resource ownership • Have a virtual address space which holds the process image • Protected access to processors, other processes, files, and I/O resources

  4. Process vs. Thread, Thread: • Related to program execution • 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 • all threads of a process share this

  5. Process vs. Thread Addr. Space Kernel Stack PCB PCB Thread CB Thread CB Thread CB Thread CB Addr. Space User Stack User Stack User Stack User Stack User Stack Kernel Stack Kernel Stack Kernel Stack Kernel Stack Single-Threaded Multithreaded

  6. Multithreading • MS-DOS - a single thread • UNIX - multiple user processes but only supports one thread per process • Java Run-Time engine - one process, multiple threads • Windows 2000, Solaris, Linux, Mach, and OS/2 - multiple threads

  7. Multithreading 1 Process 1 Thread 1 Process M Threads M Processes 1 Thread per Process M Processes N Threads

  8. 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

  9. Uses of Threads • Foreground to background work • Asynchronous processing • Speed execution • Modular program structure

  10. Remote Procedure Call Using Threads Time RPC Request RPC Request Server Server RPC Using Single Thread

  11. Remote Procedure Call Using Thread Time RPC Request Thread 1 Server RPC Request Thread 2 Server

  12. Threads within Process States • 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

  13. Thread States • States associated with a change in thread state • Spawn • Spawn another thread • Block • Unblock • Finish • Deallocate register context and stacks

  14. User-Level Threads (ULT) • All thread management is done by the application • The kernel is not aware of the existence of threads • Example: • POSIX Pthread • Mach C-thread • Solaris 2 UI-thread

  15. Kernel-Level Threads (KLT) • Kernel maintains context information for the process and the threads • Scheduling is done on a thread basis • W2K, Linux, and OS/2 are examples of this approach

  16. Combined Approaches • Example is Solaris • Thread creation done in the user space • Bulk of scheduling and synchronization of threads done in the user space • Multiple ULT from a single application are mapped onto some number of KLT

  17. Relationship Between Threads and Processes Threads:Process Description Example Systems Traditional 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, OS/2, OS/390, MACH

  18. 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

  19. Thread Issue • Cancellation • Target thread - thread to be cancelled • Asynchronous cancellation • Deferred cancellation • Thread pool • Create a number of threads at process startup and place them into a pool

  20. Conclusion • Responsiveness • Resource sharing • Economy • Utilization of multiprocessor architectures • Threads synchronization

  21. Thank You Questions?

  22. Bibliography W. Stallings, Operating Systems Prentice-Hall, 1998 A. Silberschatz, P. Galvin, G. Gagne, Operating System Concepts John Wiley & Sons, Inc. 2002

More Related