SlideShare a Scribd company logo
Chapter 5: Threads 
 Overview 
 Multithreading Models 
 Threading Issues 
 Pthreads 
 Solaris 2 Threads 
 Windows 2000 Threads 
 Linux Threads 
 Java Threads 
Silberschatz, Galvin 5.1 and Gagne Ó2002 Operating System
Single and Multithreaded 
Processes 
Silberschatz, Galvin 5.2 and Gagne Ó2002 Operating System
Benefits 
 Responsiveness 
 Resource Sharing 
 Economy 
 Utilization of MP Architectures 
Silberschatz, Galvin 5.3 and Gagne Ó2002 Operating System
User Threads 
 Thread management done by user-level threads library 
 Examples 
- POSIX Pthreads 
- Mach C-threads 
- Solaris threads 
Silberschatz, Galvin 5.4 and Gagne Ó2002 Operating System
Kernel Threads 
 Supported by the Kernel 
 Examples 
- Windows 95/98/NT/2000 
- Solaris 
- Tru64 UNIX 
- BeOS 
- Linux 
Silberschatz, Galvin 5.5 and Gagne Ó2002 Operating System
Multithreading Models 
 Many-to-One 
 One-to-One 
 Many-to-Many 
Silberschatz, Galvin 5.6 and Gagne Ó2002 Operating System
Many-to-One 
 Many user-level threads mapped to single kernel thread. 
 Used on systems that do not support kernel threads. 
Silberschatz, Galvin 5.7 and Gagne Ó2002 Operating System
Many-to-One Model 
Silberschatz, Galvin 5.8 and Gagne Ó2002 Operating System
One-to-One 
 Each user-level thread maps to kernel thread. 
 Examples 
- Windows 95/98/NT/2000 
- OS/2 
Silberschatz, Galvin 5.9 and Gagne Ó2002 Operating System
One-to-one Model 
Silberschatz, Galvin 5.10 and Gagne Ó2002 Operating System
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 
Silberschatz, Galvin 5.11 and Gagne Ó2002 Operating System
Many-to-Many Model 
Silberschatz, Galvin 5.12 and Gagne Ó2002 Operating System
Threading Issues 
 Semantics of fork() and exec() system calls. 
 Thread cancellation. 
 Signal handling 
 Thread pools 
 Thread specific data 
Silberschatz, Galvin 5.13 and Gagne Ó2002 Operating System
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. 
Silberschatz, Galvin 5.14 and Gagne Ó2002 Operating System
Solaris 2 Threads 
Silberschatz, Galvin 5.15 and Gagne Ó2002 Operating System
Solaris Process 
Silberschatz, Galvin 5.16 and Gagne Ó2002 Operating System
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 
Silberschatz, Galvin 5.17 and Gagne Ó2002 Operating System
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) 
Silberschatz, Galvin 5.18 and Gagne Ó2002 Operating System
Java Threads 
 Java threads may be created by: 
 Extending Thread class 
 Implementing the Runnable interface 
 Java threads are managed by the JVM. 
Silberschatz, Galvin 5.19 and Gagne Ó2002 Operating System
Java Thread States 
Silberschatz, Galvin 5.20 and Gagne Ó2002 Operating System

More Related Content

What's hot

Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
Tech_MX
 
Real Time Kernels
Real Time KernelsReal Time Kernels
Real Time Kernels
Arnav Soni
 

What's hot (20)

Ch1
Ch1Ch1
Ch1
 
Chapter 1: Introduction to Operating System
Chapter 1: Introduction to Operating SystemChapter 1: Introduction to Operating System
Chapter 1: Introduction to Operating System
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Ch4 threads
Ch4 threadsCh4 threads
Ch4 threads
 
Unit 1 ppt
Unit 1 pptUnit 1 ppt
Unit 1 ppt
 
OS_Ch4
OS_Ch4OS_Ch4
OS_Ch4
 
Ch1-Operating System Concept
Ch1-Operating System ConceptCh1-Operating System Concept
Ch1-Operating System Concept
 
cs8493 - operating systems unit 2
cs8493 - operating systems unit 2cs8493 - operating systems unit 2
cs8493 - operating systems unit 2
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementation
 
Main memory operating system
Main memory   operating systemMain memory   operating system
Main memory operating system
 
Operating System-Ch8 memory management
Operating System-Ch8 memory managementOperating System-Ch8 memory management
Operating System-Ch8 memory management
 
Memory management in_windows_os
Memory management in_windows_osMemory management in_windows_os
Memory management in_windows_os
 
Os rtos.ppt
Os rtos.pptOs rtos.ppt
Os rtos.ppt
 
Tuned
TunedTuned
Tuned
 
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockOperating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
 
1 intro and overview
1 intro and overview1 intro and overview
1 intro and overview
 
Chapter 3: Processes
Chapter 3: ProcessesChapter 3: Processes
Chapter 3: Processes
 
Real Time Kernels
Real Time KernelsReal Time Kernels
Real Time Kernels
 
2 os structure
2 os structure2 os structure
2 os structure
 
Vxworks
VxworksVxworks
Vxworks
 

Viewers also liked

Galvin-operating System(Ch7)
Galvin-operating System(Ch7)Galvin-operating System(Ch7)
Galvin-operating System(Ch7)
dsuyal1
 
Galvin-operating System(Ch10)
Galvin-operating System(Ch10)Galvin-operating System(Ch10)
Galvin-operating System(Ch10)
dsuyal1
 
Galvin-operating System(Ch6)
Galvin-operating System(Ch6)Galvin-operating System(Ch6)
Galvin-operating System(Ch6)
dsuyal1
 
Galvin-operating System(Ch8)
Galvin-operating System(Ch8)Galvin-operating System(Ch8)
Galvin-operating System(Ch8)
dsuyal1
 
Operating Systems and Utility Programs
Operating Systems and Utility ProgramsOperating Systems and Utility Programs
Operating Systems and Utility Programs
Samudin Kassan
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
Sonali Chauhan
 

Viewers also liked (17)

4.Threads
4.Threads4.Threads
4.Threads
 
OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Concepts
 
Galvin-operating System(Ch7)
Galvin-operating System(Ch7)Galvin-operating System(Ch7)
Galvin-operating System(Ch7)
 
Galvin-operating System(Ch10)
Galvin-operating System(Ch10)Galvin-operating System(Ch10)
Galvin-operating System(Ch10)
 
Galvin-operating System(Ch6)
Galvin-operating System(Ch6)Galvin-operating System(Ch6)
Galvin-operating System(Ch6)
 
Ch4 Threads
Ch4 ThreadsCh4 Threads
Ch4 Threads
 
Galvin-operating System(Ch8)
Galvin-operating System(Ch8)Galvin-operating System(Ch8)
Galvin-operating System(Ch8)
 
Unit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - ThreadsUnit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - Threads
 
Circuit and analog electronics ch6
Circuit and analog electronics ch6  Circuit and analog electronics ch6
Circuit and analog electronics ch6
 
Real time Scheduling in Operating System for Msc CS
Real time Scheduling in Operating System for Msc CSReal time Scheduling in Operating System for Msc CS
Real time Scheduling in Operating System for Msc CS
 
Ch3: Operating System Structure
Ch3: Operating System StructureCh3: Operating System Structure
Ch3: Operating System Structure
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programming
 
Threads
ThreadsThreads
Threads
 
Operating Systems and Utility Programs
Operating Systems and Utility ProgramsOperating Systems and Utility Programs
Operating Systems and Utility Programs
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
 
operating system
operating systemoperating system
operating system
 
Lecture 1 introduction to Operating System
Lecture 1 introduction to Operating SystemLecture 1 introduction to Operating System
Lecture 1 introduction to Operating System
 

Similar to Galvin-operating System(Ch5)

Ch5 OS
Ch5 OSCh5 OS
Ch5 OS
C.U
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)
Nagarajan
 

Similar to Galvin-operating System(Ch5) (20)

ch5.ppt
ch5.pptch5.ppt
ch5.ppt
 
Ch5 threads galvin
Ch5 threads  galvinCh5 threads  galvin
Ch5 threads galvin
 
Ch5: Threads (Operating System)
Ch5: Threads (Operating System)Ch5: Threads (Operating System)
Ch5: Threads (Operating System)
 
Operating System : Ch4 b threads
Operating System : Ch4 b threadsOperating System : Ch4 b threads
Operating System : Ch4 b threads
 
Ch5 OS
Ch5 OSCh5 OS
Ch5 OS
 
OSCh5
OSCh5OSCh5
OSCh5
 
OS_Ch5
OS_Ch5OS_Ch5
OS_Ch5
 
Ch4 threads
Ch4  threadsCh4  threads
Ch4 threads
 
My DIaries
My DIariesMy DIaries
My DIaries
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)
 
Thread
ThreadThread
Thread
 
Threads are using in operating systems.pptx
Threads are using in operating systems.pptxThreads are using in operating systems.pptx
Threads are using in operating systems.pptx
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
Threads & Concurrency
Threads & Concurrency Threads & Concurrency
Threads & Concurrency
 
ch4.ppt
ch4.pptch4.ppt
ch4.ppt
 
ch4.ppt
ch4.pptch4.ppt
ch4.ppt
 
ch4.ppt
ch4.pptch4.ppt
ch4.ppt
 
ch4.ppt operation system. Dats structure and alogor
ch4.ppt operation system. Dats structure and alogorch4.ppt operation system. Dats structure and alogor
ch4.ppt operation system. Dats structure and alogor
 
Threads semaphoremutexlocksdeadlockp.ppt
Threads semaphoremutexlocksdeadlockp.pptThreads semaphoremutexlocksdeadlockp.ppt
Threads semaphoremutexlocksdeadlockp.ppt
 
ch4.pptx
ch4.pptxch4.pptx
ch4.pptx
 

Galvin-operating System(Ch5)

  • 1. Chapter 5: Threads Overview Multithreading Models Threading Issues Pthreads Solaris 2 Threads Windows 2000 Threads Linux Threads Java Threads Silberschatz, Galvin 5.1 and Gagne Ó2002 Operating System
  • 2. Single and Multithreaded Processes Silberschatz, Galvin 5.2 and Gagne Ó2002 Operating System
  • 3. Benefits Responsiveness Resource Sharing Economy Utilization of MP Architectures Silberschatz, Galvin 5.3 and Gagne Ó2002 Operating System
  • 4. User Threads Thread management done by user-level threads library Examples - POSIX Pthreads - Mach C-threads - Solaris threads Silberschatz, Galvin 5.4 and Gagne Ó2002 Operating System
  • 5. Kernel Threads Supported by the Kernel Examples - Windows 95/98/NT/2000 - Solaris - Tru64 UNIX - BeOS - Linux Silberschatz, Galvin 5.5 and Gagne Ó2002 Operating System
  • 6. Multithreading Models Many-to-One One-to-One Many-to-Many Silberschatz, Galvin 5.6 and Gagne Ó2002 Operating System
  • 7. Many-to-One Many user-level threads mapped to single kernel thread. Used on systems that do not support kernel threads. Silberschatz, Galvin 5.7 and Gagne Ó2002 Operating System
  • 8. Many-to-One Model Silberschatz, Galvin 5.8 and Gagne Ó2002 Operating System
  • 9. One-to-One Each user-level thread maps to kernel thread. Examples - Windows 95/98/NT/2000 - OS/2 Silberschatz, Galvin 5.9 and Gagne Ó2002 Operating System
  • 10. One-to-one Model Silberschatz, Galvin 5.10 and Gagne Ó2002 Operating System
  • 11. 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 Silberschatz, Galvin 5.11 and Gagne Ó2002 Operating System
  • 12. Many-to-Many Model Silberschatz, Galvin 5.12 and Gagne Ó2002 Operating System
  • 13. Threading Issues Semantics of fork() and exec() system calls. Thread cancellation. Signal handling Thread pools Thread specific data Silberschatz, Galvin 5.13 and Gagne Ó2002 Operating System
  • 14. 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. Silberschatz, Galvin 5.14 and Gagne Ó2002 Operating System
  • 15. Solaris 2 Threads Silberschatz, Galvin 5.15 and Gagne Ó2002 Operating System
  • 16. Solaris Process Silberschatz, Galvin 5.16 and Gagne Ó2002 Operating System
  • 17. 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 Silberschatz, Galvin 5.17 and Gagne Ó2002 Operating System
  • 18. 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) Silberschatz, Galvin 5.18 and Gagne Ó2002 Operating System
  • 19. Java Threads Java threads may be created by: Extending Thread class Implementing the Runnable interface Java threads are managed by the JVM. Silberschatz, Galvin 5.19 and Gagne Ó2002 Operating System
  • 20. Java Thread States Silberschatz, Galvin 5.20 and Gagne Ó2002 Operating System