chapter 5 threads
play

Chapter 5: Threads I Overview I Multithreading Models I Threading - PDF document

Chapter 5: Threads I Overview I Multithreading Models I Threading Issues I Pthreads I Solaris 2 Threads I Windows 2000 Threads I Linux Threads I Java Threads Silberschatz, Galvin and Gagne 2002 Operating System Concepts 5.1 Single and


  1. Chapter 5: Threads I Overview I Multithreading Models I Threading Issues I Pthreads I Solaris 2 Threads I Windows 2000 Threads I Linux Threads I Java Threads Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.1 Single and Multithreaded Processes Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.2 1

  2. Benefits I Responsiveness I Resource Sharing I Economy I Utilization of MP Architectures Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.3 User Threads I Thread management done by user-level threads library I Examples - POSIX Pthreads - Mach C-threads - Solaris threads Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.4 2

  3. Kernel Threads I Supported by the Kernel I Examples - Windows 95/98/NT/2000 - Solaris - Tru64 UNIX - BeOS - Linux Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.5 Multithreading Models I Many-to-One I One-to-One I Many-to-Many Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.6 3

  4. Many-to-One I Many user-level threads mapped to single kernel thread. I Used on systems that do not support kernel threads. Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.7 Many-to-One Model Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.8 4

  5. One-to-One I Each user-level thread maps to kernel thread. I Examples - Windows 95/98/NT/2000 - OS/2 Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.9 One-to-one Model Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.10 5

  6. Many-to-Many Model I Allows many user level threads to be mapped to many kernel threads. I Allows the operating system to create a sufficient number of kernel threads. I Solaris 2 I Windows NT/2000 with the ThreadFiber package Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.11 Many-to-Many Model Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.12 6

  7. Threading Issues I Semantics of fork() and exec() system calls. I Thread cancellation. I Signal handling I Thread pools I Thread specific data Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.13 Pthreads I a POSIX standard (IEEE 1003.1c) API for thread creation and synchronization. I API specifies behavior of the thread library, implementation is up to development of the library. I Common in UNIX operating systems. Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.14 7

  8. Solaris 2 Threads Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.15 Solaris Process Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.16 8

  9. Windows 2000 Threads I Implements the one-to-one mapping. I Each thread contains - a thread id - register set - separate user and kernel stacks - private data storage area Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.17 Linux Threads I Linux refers to them as tasks rather than threads . I Thread creation is done through clone() system call. I Clone() allows a child task to share the address space of the parent task (process) Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.18 9

  10. Java Threads I Java threads may be created by: ! Extending Thread class ! Implementing the Runnable interface I Java threads are managed by the JVM. Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.19 Java Thread States Silberschatz, Galvin and Gagne  2002 Operating System Concepts 5.20 10

Recommend


More recommend