ch5: threads (operating system)
TRANSCRIPT
![Page 1: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/1.jpg)
Silberschatz, Galvin and Gagne 20025.1Operating System Concepts
Chapter 5: Threads
Overview Multithreading Models Threading Issues Pthreads Solaris 2 Threads Windows 2000 Threads Linux Threads Java Threads
![Page 2: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/2.jpg)
Silberschatz, Galvin and Gagne 20025.2Operating System Concepts
Single and Multithreaded Processes
![Page 3: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/3.jpg)
Silberschatz, Galvin and Gagne 20025.3Operating System Concepts
Benefits
Responsiveness
Resource Sharing
Economy
Utilization of MP Architectures
![Page 4: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/4.jpg)
Silberschatz, Galvin and Gagne 20025.4Operating System Concepts
User Threads
Thread management done by user-level threads library
Examples- POSIX Pthreads- Mach C-threads- Solaris threads
![Page 5: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/5.jpg)
Silberschatz, Galvin and Gagne 20025.5Operating System Concepts
Kernel Threads
Supported by the Kernel
Examples- Windows 95/98/NT/2000
- Solaris- Tru64 UNIX- BeOS- Linux
![Page 6: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/6.jpg)
Silberschatz, Galvin and Gagne 20025.6Operating System Concepts
Multithreading Models
Many-to-One
One-to-One
Many-to-Many
![Page 7: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/7.jpg)
Silberschatz, Galvin and Gagne 20025.7Operating System Concepts
Many-to-One
Many user-level threads mapped to single kernel thread.
Used on systems that do not support kernel threads.
![Page 8: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/8.jpg)
Silberschatz, Galvin and Gagne 20025.8Operating System Concepts
Many-to-One Model
![Page 9: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/9.jpg)
Silberschatz, Galvin and Gagne 20025.9Operating System Concepts
One-to-One
Each user-level thread maps to kernel thread.
Examples- Windows 95/98/NT/2000- OS/2
![Page 10: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/10.jpg)
Silberschatz, Galvin and Gagne 20025.10Operating System Concepts
One-to-one Model
![Page 11: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/11.jpg)
Silberschatz, Galvin and Gagne 20025.11Operating System Concepts
Many-to-Many Model
Allows many user level threads to be mapped to many kernel threads.
Allows the operating system to create a sufficient number of kernel threads.
Solaris 2 Windows NT/2000 with the ThreadFiber package
![Page 12: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/12.jpg)
Silberschatz, Galvin and Gagne 20025.12Operating System Concepts
Many-to-Many Model
![Page 13: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/13.jpg)
Silberschatz, Galvin and Gagne 20025.13Operating System Concepts
Threading Issues
Semantics of fork() and exec() system calls. Thread cancellation. Signal handling Thread pools Thread specific data
![Page 14: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/14.jpg)
Silberschatz, Galvin and Gagne 20025.14Operating System Concepts
Pthreads
a POSIX standard (IEEE 1003.1c) API for thread creation and synchronization.
API specifies behavior of the thread library, implementation is up to development of the library.
Common in UNIX operating systems.
![Page 15: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/15.jpg)
Silberschatz, Galvin and Gagne 20025.15Operating System Concepts
Solaris 2 Threads
![Page 16: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/16.jpg)
Silberschatz, Galvin and Gagne 20025.16Operating System Concepts
Solaris Process
![Page 17: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/17.jpg)
Silberschatz, Galvin and Gagne 20025.17Operating System Concepts
Windows 2000 Threads
Implements the one-to-one mapping. Each thread contains
- a thread id- register set- separate user and kernel stacks- private data storage area
![Page 18: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/18.jpg)
Silberschatz, Galvin and Gagne 20025.18Operating System Concepts
Linux Threads
Linux refers to them as tasks rather than threads. Thread creation is done through clone() system call. Clone() allows a child task to share the address space of
the parent task (process)
![Page 19: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/19.jpg)
Silberschatz, Galvin and Gagne 20025.19Operating System Concepts
Java Threads
Java threads may be created by:
Extending Thread class Implementing the Runnable interface
Java threads are managed by the JVM.
![Page 20: Ch5: Threads (Operating System)](https://reader036.vdocument.in/reader036/viewer/2022073023/58a76aa71a28ab99238b4b33/html5/thumbnails/20.jpg)
Silberschatz, Galvin and Gagne 20025.20Operating System Concepts
Java Thread States