SlideShare a Scribd company logo
Chapter 4: ThreadsChapter 4: Threads
4.2 Silberschatz, Galvin and GagneOperating System Concepts
Chapter 4: ThreadsChapter 4: Threads
Overview
Multithreading Models
Threading Issues
Pthreads
Windows XP Threads
Linux Threads
Java Threads
4.3 Silberschatz, Galvin and GagneOperating System Concepts
Single and Multithreaded ProcessesSingle and Multithreaded Processes
4.4 Silberschatz, Galvin and GagneOperating System Concepts
BenefitsBenefits
Responsiveness
Resource Sharing
Economy
Utilization of MP Architectures
4.5 Silberschatz, Galvin and GagneOperating System Concepts
User ThreadsUser Threads
Thread management done by user-level threads library
Three primary thread libraries:
POSIX Pthreads
Win32 threads
Java threads
4.6 Silberschatz, Galvin and GagneOperating System Concepts
Kernel ThreadsKernel Threads
Supported by the Kernel
Examples
Windows XP/2000
Solaris
Linux
Tru64 UNIX
Mac OS X
4.7 Silberschatz, Galvin and GagneOperating System Concepts
Multithreading ModelsMultithreading Models
Many-to-One
One-to-One
Many-to-Many
4.8 Silberschatz, Galvin and GagneOperating System Concepts
Many-to-OneMany-to-One
Many user-level threads mapped to single kernel thread
Examples:
Solaris Green Threads
GNU Portable Threads
4.9 Silberschatz, Galvin and GagneOperating System Concepts
Many-to-One ModelMany-to-One Model
4.10 Silberschatz, Galvin and GagneOperating System Concepts
One-to-OneOne-to-One
Each user-level thread maps to kernel thread
Examples
Windows NT/XP/2000
Linux
Solaris 9 and later
4.11 Silberschatz, Galvin and GagneOperating System Concepts
One-to-one ModelOne-to-one Model
4.12 Silberschatz, Galvin and GagneOperating System Concepts
Many-to-Many ModelMany-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 prior to version 9
Windows NT/2000 with the ThreadFiber package
4.13 Silberschatz, Galvin and GagneOperating System Concepts
Many-to-Many ModelMany-to-Many Model
4.14 Silberschatz, Galvin and GagneOperating System Concepts
Two-level ModelTwo-level Model
Similar to M:M, except that it allows a user thread to be
bound to kernel thread
Examples
IRIX
HP-UX
Tru64 UNIX
Solaris 8 and earlier
4.15 Silberschatz, Galvin and GagneOperating System Concepts
Two-level ModelTwo-level Model
4.16 Silberschatz, Galvin and GagneOperating System Concepts
Threading IssuesThreading Issues
Semantics of fork() and exec() system calls
Thread cancellation
Signal handling
Thread pools
Thread specific data
Scheduler activations
4.17 Silberschatz, Galvin and GagneOperating System Concepts
Semantics of fork() and exec()Semantics of fork() and exec()
Does fork() duplicate only the calling thread or all threads?
4.18 Silberschatz, Galvin and GagneOperating System Concepts
Thread CancellationThread Cancellation
Terminating a thread before it has finished
Two general approaches:
Asynchronous cancellation terminates the target
thread immediately
Deferred cancellation allows the target thread to
periodically check if it should be cancelled
4.19 Silberschatz, Galvin and GagneOperating System Concepts
Signal HandlingSignal Handling
Signals are used in UNIX systems to notify a process that a
particular event has occurred
A signal handler is used to process signals
1. Signal is generated by particular event
2. Signal is delivered to a process
3. Signal is handled
Options:
Deliver the signal to the thread to which the signal applies
Deliver the signal to every thread in the process
Deliver the signal to certain threads in the process
Assign a specific threa to receive all signals for the process
4.20 Silberschatz, Galvin and GagneOperating System Concepts
Thread PoolsThread Pools
Create a number of threads in a pool where they await work
Advantages:
Usually slightly faster to service a request with an existing
thread than create a new thread
Allows the number of threads in the application(s) to be
bound to the size of the pool
4.21 Silberschatz, Galvin and GagneOperating System Concepts
Thread Specific DataThread Specific Data
Allows each thread to have its own copy of data
Useful when you do not have control over the thread
creation process (i.e., when using a thread pool)
4.22 Silberschatz, Galvin and GagneOperating System Concepts
Scheduler ActivationsScheduler Activations
Both M:M and Two-level models require communication to
maintain the appropriate number of kernel threads allocated
to the application
Scheduler activations provide upcalls - a communication
mechanism from the kernel to the thread library
This communication allows an application to maintain the
correct number kernel threads
4.23 Silberschatz, Galvin and GagneOperating System Concepts
PthreadsPthreads
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 (Solaris, Linux,
Mac OS X)
4.24 Silberschatz, Galvin and GagneOperating System Concepts
Windows XP ThreadsWindows XP Threads
Implements the one-to-one mapping
Each thread contains
A thread id
Register set
Separate user and kernel stacks
Private data storage area
The register set, stacks, and private storage area are known
as the context of the threads
The primary data structures of a thread include:
ETHREAD (executive thread block)
KTHREAD (kernel thread block)
TEB (thread environment block)
4.25 Silberschatz, Galvin and GagneOperating System Concepts
Linux ThreadsLinux 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)
4.26 Silberschatz, Galvin and GagneOperating System Concepts
Java ThreadsJava Threads
Java threads are managed by the JVM
Java threads may be created by:
Extending Thread class
Implementing the Runnable interface
4.27 Silberschatz, Galvin and GagneOperating System Concepts
Java Thread StatesJava Thread States
End of Chapter 4End of Chapter 4

More Related Content

What's hot

System Programming - Interprocess communication
System Programming - Interprocess communicationSystem Programming - Interprocess communication
System Programming - Interprocess communication
HelpWithAssignment.com
 
Pthread
PthreadPthread
Pthread
Gopi Saiteja
 
seL4 intro
seL4 introseL4 intro
seL4 intro
microkerneldude
 
Introduction to freebsd_6_kernel_hacking
Introduction to freebsd_6_kernel_hackingIntroduction to freebsd_6_kernel_hacking
Introduction to freebsd_6_kernel_hacking
Susant Sahani
 
Ch4 threads
Ch4   threadsCh4   threads
Ch4 threads
Welly Dian Astika
 
Attackboard slides dac12-0605
Attackboard slides dac12-0605Attackboard slides dac12-0605
Attackboard slides dac12-0605
Yoshi Shih-Chieh Huang
 
unix interprocess communication
unix interprocess communicationunix interprocess communication
unix interprocess communication
guest4c9430
 

What's hot (7)

System Programming - Interprocess communication
System Programming - Interprocess communicationSystem Programming - Interprocess communication
System Programming - Interprocess communication
 
Pthread
PthreadPthread
Pthread
 
seL4 intro
seL4 introseL4 intro
seL4 intro
 
Introduction to freebsd_6_kernel_hacking
Introduction to freebsd_6_kernel_hackingIntroduction to freebsd_6_kernel_hacking
Introduction to freebsd_6_kernel_hacking
 
Ch4 threads
Ch4   threadsCh4   threads
Ch4 threads
 
Attackboard slides dac12-0605
Attackboard slides dac12-0605Attackboard slides dac12-0605
Attackboard slides dac12-0605
 
unix interprocess communication
unix interprocess communicationunix interprocess communication
unix interprocess communication
 

Viewers also liked

Galvin-operating System(Ch5)
Galvin-operating System(Ch5)Galvin-operating System(Ch5)
Galvin-operating System(Ch5)
dsuyal1
 
OS Process and Thread Concepts
OS Process and Thread ConceptsOS Process and Thread Concepts
OS Process and Thread Concepts
sgpraju
 
Galvin-operating System(Ch7)
Galvin-operating System(Ch7)Galvin-operating System(Ch7)
Galvin-operating System(Ch7)
dsuyal1
 
Galvin-operating System(Ch3)
Galvin-operating System(Ch3)Galvin-operating System(Ch3)
Galvin-operating System(Ch3)
dsuyal1
 
Galvin-operating System(Ch9)
Galvin-operating System(Ch9)Galvin-operating System(Ch9)
Galvin-operating System(Ch9)
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
 
Ch4 Threads
Ch4 ThreadsCh4 Threads
Ch4 Threads
mayacendana
 
Galvin-operating System(Ch8)
Galvin-operating System(Ch8)Galvin-operating System(Ch8)
Galvin-operating System(Ch8)
dsuyal1
 
Unit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - ThreadsUnit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - Threads
cscarcas
 
Ch5: Threads (Operating System)
Ch5: Threads (Operating System)Ch5: Threads (Operating System)
Ch5: Threads (Operating System)
Ahmar Hashmi
 
Circuit and analog electronics ch6
Circuit and analog electronics ch6  Circuit and analog electronics ch6
Circuit and analog electronics ch6
Nadhiien Abraham
 
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
Thanveen
 
Ch3: Operating System Structure
Ch3: Operating System StructureCh3: Operating System Structure
Ch3: Operating System Structure
Ahmar Hashmi
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programming
guesta40f80
 
Threads
ThreadsThreads
Threads
Shivam Singh
 
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
 
operating system
operating systemoperating system
operating system
Ibbad shah
 
Lecture 1 introduction to Operating System
Lecture 1 introduction to Operating SystemLecture 1 introduction to Operating System
Lecture 1 introduction to Operating System
Dr. Amitava Nag
 

Viewers also liked (20)

Galvin-operating System(Ch5)
Galvin-operating System(Ch5)Galvin-operating System(Ch5)
Galvin-operating System(Ch5)
 
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(Ch3)
Galvin-operating System(Ch3)Galvin-operating System(Ch3)
Galvin-operating System(Ch3)
 
Galvin-operating System(Ch9)
Galvin-operating System(Ch9)Galvin-operating System(Ch9)
Galvin-operating System(Ch9)
 
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
 
Ch5: Threads (Operating System)
Ch5: Threads (Operating System)Ch5: Threads (Operating System)
Ch5: Threads (Operating System)
 
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 4.Threads

Chapter 4 - Threads
Chapter 4 - ThreadsChapter 4 - Threads
Chapter 4 - Threads
Wayne Jones Jnr
 
CH04.pdf
CH04.pdfCH04.pdf
CH04.pdf
ImranKhan880955
 
Ch4 threads
Ch4 threadsCh4 threads
Ch4 threads
Ankit Dubey
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
Ra'Fat Al-Msie'deen
 
Ch5 OS
Ch5 OSCh5 OS
Ch5 OS
C.U
 
Os
OsOs
OSCh5
OSCh5OSCh5
OS_Ch5
OS_Ch5OS_Ch5
Sucet os module_2_notes
Sucet os module_2_notesSucet os module_2_notes
Sucet os module_2_notes
SRINIVASUNIVERSITYEN
 
ch5.ppt
ch5.pptch5.ppt
ch5.ppt
SanjidIhsan
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
AnyapuPranav
 
My DIaries
My DIariesMy DIaries
My DIaries
Mehak Raza
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
bleh23
 
Threads
ThreadsThreads
Threads
SURBHI SAROHA
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
mona_hakmy
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
tech2click
 
Operating system 22 threading issues
Operating system 22 threading issuesOperating system 22 threading issues
Operating system 22 threading issues
Vaibhav Khanna
 
multi-threading
multi-threadingmulti-threading
multi-threading
Ezzat Gul
 
4 threads
4 threads4 threads
4 threads
Dr. Loganathan R
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)
Nagarajan
 

Similar to 4.Threads (20)

Chapter 4 - Threads
Chapter 4 - ThreadsChapter 4 - Threads
Chapter 4 - Threads
 
CH04.pdf
CH04.pdfCH04.pdf
CH04.pdf
 
Ch4 threads
Ch4 threadsCh4 threads
Ch4 threads
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
Ch5 OS
Ch5 OSCh5 OS
Ch5 OS
 
Os
OsOs
Os
 
OSCh5
OSCh5OSCh5
OSCh5
 
OS_Ch5
OS_Ch5OS_Ch5
OS_Ch5
 
Sucet os module_2_notes
Sucet os module_2_notesSucet os module_2_notes
Sucet os module_2_notes
 
ch5.ppt
ch5.pptch5.ppt
ch5.ppt
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
 
My DIaries
My DIariesMy DIaries
My DIaries
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
Threads
ThreadsThreads
Threads
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
 
Operating system 22 threading issues
Operating system 22 threading issuesOperating system 22 threading issues
Operating system 22 threading issues
 
multi-threading
multi-threadingmulti-threading
multi-threading
 
4 threads
4 threads4 threads
4 threads
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)
 

More from Senthil Kanth

Wireless Communication and Networking by WilliamStallings Chap2
Wireless Communication and Networking  by WilliamStallings Chap2Wireless Communication and Networking  by WilliamStallings Chap2
Wireless Communication and Networking by WilliamStallings Chap2
Senthil Kanth
 
wireless communication and networking Chapter 1
wireless communication and networking Chapter 1wireless communication and networking Chapter 1
wireless communication and networking Chapter 1
Senthil Kanth
 
WML Script by Shanti katta
WML Script by Shanti kattaWML Script by Shanti katta
WML Script by Shanti katta
Senthil Kanth
 
WAP- Wireless Application Protocol
WAP- Wireless Application ProtocolWAP- Wireless Application Protocol
WAP- Wireless Application Protocol
Senthil Kanth
 
What is WAP?
What is WAP?What is WAP?
What is WAP?
Senthil Kanth
 
Introduction to Mobile Application Development
Introduction to Mobile Application DevelopmentIntroduction to Mobile Application Development
Introduction to Mobile Application Development
Senthil Kanth
 
Markup Languages
Markup Languages Markup Languages
Markup Languages
Senthil Kanth
 
MOBILE APPs DEVELOPMENT PLATFORMS
MOBILE APPs DEVELOPMENT PLATFORMSMOBILE APPs DEVELOPMENT PLATFORMS
MOBILE APPs DEVELOPMENT PLATFORMS
Senthil Kanth
 
Introduction to wireless application protocol (wap)ogi
Introduction to wireless application protocol (wap)ogiIntroduction to wireless application protocol (wap)ogi
Introduction to wireless application protocol (wap)ogi
Senthil Kanth
 
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEEXML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
Senthil Kanth
 
Wireless Application Protocol WAP by Alvinen
Wireless Application Protocol WAP by AlvinenWireless Application Protocol WAP by Alvinen
Wireless Application Protocol WAP by Alvinen
Senthil Kanth
 
HR QUESTIONS, INTERVIEW QUESTIONS
HR QUESTIONS, INTERVIEW QUESTIONSHR QUESTIONS, INTERVIEW QUESTIONS
HR QUESTIONS, INTERVIEW QUESTIONS
Senthil Kanth
 
HR QUESTIONS
HR QUESTIONSHR QUESTIONS
HR QUESTIONS
Senthil Kanth
 
STOCK APPLICATION USING CORBA
STOCK APPLICATION USING CORBASTOCK APPLICATION USING CORBA
STOCK APPLICATION USING CORBA
Senthil Kanth
 
RSA alogrithm
RSA alogrithmRSA alogrithm
RSA alogrithm
Senthil Kanth
 
Zone Routing Protocol (ZRP)
Zone Routing Protocol (ZRP)Zone Routing Protocol (ZRP)
Zone Routing Protocol (ZRP)
Senthil Kanth
 
On-Demand Multicast Routing Protocol
On-Demand Multicast Routing ProtocolOn-Demand Multicast Routing Protocol
On-Demand Multicast Routing Protocol
Senthil Kanth
 
Adhoc routing protocols
Adhoc routing protocolsAdhoc routing protocols
Adhoc routing protocols
Senthil Kanth
 
DSDV VS AODV
DSDV VS AODV DSDV VS AODV
DSDV VS AODV
Senthil Kanth
 
16.Distributed System Structure
16.Distributed System Structure16.Distributed System Structure
16.Distributed System Structure
Senthil Kanth
 

More from Senthil Kanth (20)

Wireless Communication and Networking by WilliamStallings Chap2
Wireless Communication and Networking  by WilliamStallings Chap2Wireless Communication and Networking  by WilliamStallings Chap2
Wireless Communication and Networking by WilliamStallings Chap2
 
wireless communication and networking Chapter 1
wireless communication and networking Chapter 1wireless communication and networking Chapter 1
wireless communication and networking Chapter 1
 
WML Script by Shanti katta
WML Script by Shanti kattaWML Script by Shanti katta
WML Script by Shanti katta
 
WAP- Wireless Application Protocol
WAP- Wireless Application ProtocolWAP- Wireless Application Protocol
WAP- Wireless Application Protocol
 
What is WAP?
What is WAP?What is WAP?
What is WAP?
 
Introduction to Mobile Application Development
Introduction to Mobile Application DevelopmentIntroduction to Mobile Application Development
Introduction to Mobile Application Development
 
Markup Languages
Markup Languages Markup Languages
Markup Languages
 
MOBILE APPs DEVELOPMENT PLATFORMS
MOBILE APPs DEVELOPMENT PLATFORMSMOBILE APPs DEVELOPMENT PLATFORMS
MOBILE APPs DEVELOPMENT PLATFORMS
 
Introduction to wireless application protocol (wap)ogi
Introduction to wireless application protocol (wap)ogiIntroduction to wireless application protocol (wap)ogi
Introduction to wireless application protocol (wap)ogi
 
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEEXML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
XML Programming WML by Dickson K.W. Chiu PhD, SMIEEE
 
Wireless Application Protocol WAP by Alvinen
Wireless Application Protocol WAP by AlvinenWireless Application Protocol WAP by Alvinen
Wireless Application Protocol WAP by Alvinen
 
HR QUESTIONS, INTERVIEW QUESTIONS
HR QUESTIONS, INTERVIEW QUESTIONSHR QUESTIONS, INTERVIEW QUESTIONS
HR QUESTIONS, INTERVIEW QUESTIONS
 
HR QUESTIONS
HR QUESTIONSHR QUESTIONS
HR QUESTIONS
 
STOCK APPLICATION USING CORBA
STOCK APPLICATION USING CORBASTOCK APPLICATION USING CORBA
STOCK APPLICATION USING CORBA
 
RSA alogrithm
RSA alogrithmRSA alogrithm
RSA alogrithm
 
Zone Routing Protocol (ZRP)
Zone Routing Protocol (ZRP)Zone Routing Protocol (ZRP)
Zone Routing Protocol (ZRP)
 
On-Demand Multicast Routing Protocol
On-Demand Multicast Routing ProtocolOn-Demand Multicast Routing Protocol
On-Demand Multicast Routing Protocol
 
Adhoc routing protocols
Adhoc routing protocolsAdhoc routing protocols
Adhoc routing protocols
 
DSDV VS AODV
DSDV VS AODV DSDV VS AODV
DSDV VS AODV
 
16.Distributed System Structure
16.Distributed System Structure16.Distributed System Structure
16.Distributed System Structure
 

Recently uploaded

Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
IsmaelVazquez38
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
JomonJoseph58
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
indexPub
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 

Recently uploaded (20)

Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 

4.Threads

  • 2. 4.2 Silberschatz, Galvin and GagneOperating System Concepts Chapter 4: ThreadsChapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads
  • 3. 4.3 Silberschatz, Galvin and GagneOperating System Concepts Single and Multithreaded ProcessesSingle and Multithreaded Processes
  • 4. 4.4 Silberschatz, Galvin and GagneOperating System Concepts BenefitsBenefits Responsiveness Resource Sharing Economy Utilization of MP Architectures
  • 5. 4.5 Silberschatz, Galvin and GagneOperating System Concepts User ThreadsUser Threads Thread management done by user-level threads library Three primary thread libraries: POSIX Pthreads Win32 threads Java threads
  • 6. 4.6 Silberschatz, Galvin and GagneOperating System Concepts Kernel ThreadsKernel Threads Supported by the Kernel Examples Windows XP/2000 Solaris Linux Tru64 UNIX Mac OS X
  • 7. 4.7 Silberschatz, Galvin and GagneOperating System Concepts Multithreading ModelsMultithreading Models Many-to-One One-to-One Many-to-Many
  • 8. 4.8 Silberschatz, Galvin and GagneOperating System Concepts Many-to-OneMany-to-One Many user-level threads mapped to single kernel thread Examples: Solaris Green Threads GNU Portable Threads
  • 9. 4.9 Silberschatz, Galvin and GagneOperating System Concepts Many-to-One ModelMany-to-One Model
  • 10. 4.10 Silberschatz, Galvin and GagneOperating System Concepts One-to-OneOne-to-One Each user-level thread maps to kernel thread Examples Windows NT/XP/2000 Linux Solaris 9 and later
  • 11. 4.11 Silberschatz, Galvin and GagneOperating System Concepts One-to-one ModelOne-to-one Model
  • 12. 4.12 Silberschatz, Galvin and GagneOperating System Concepts Many-to-Many ModelMany-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 prior to version 9 Windows NT/2000 with the ThreadFiber package
  • 13. 4.13 Silberschatz, Galvin and GagneOperating System Concepts Many-to-Many ModelMany-to-Many Model
  • 14. 4.14 Silberschatz, Galvin and GagneOperating System Concepts Two-level ModelTwo-level Model Similar to M:M, except that it allows a user thread to be bound to kernel thread Examples IRIX HP-UX Tru64 UNIX Solaris 8 and earlier
  • 15. 4.15 Silberschatz, Galvin and GagneOperating System Concepts Two-level ModelTwo-level Model
  • 16. 4.16 Silberschatz, Galvin and GagneOperating System Concepts Threading IssuesThreading Issues Semantics of fork() and exec() system calls Thread cancellation Signal handling Thread pools Thread specific data Scheduler activations
  • 17. 4.17 Silberschatz, Galvin and GagneOperating System Concepts Semantics of fork() and exec()Semantics of fork() and exec() Does fork() duplicate only the calling thread or all threads?
  • 18. 4.18 Silberschatz, Galvin and GagneOperating System Concepts Thread CancellationThread Cancellation Terminating a thread before it has finished Two general approaches: Asynchronous cancellation terminates the target thread immediately Deferred cancellation allows the target thread to periodically check if it should be cancelled
  • 19. 4.19 Silberschatz, Galvin and GagneOperating System Concepts Signal HandlingSignal Handling Signals are used in UNIX systems to notify a process that a particular event has occurred A signal handler is used to process signals 1. Signal is generated by particular event 2. Signal is delivered to a process 3. Signal is handled Options: Deliver the signal to the thread to which the signal applies Deliver the signal to every thread in the process Deliver the signal to certain threads in the process Assign a specific threa to receive all signals for the process
  • 20. 4.20 Silberschatz, Galvin and GagneOperating System Concepts Thread PoolsThread Pools Create a number of threads in a pool where they await work Advantages: Usually slightly faster to service a request with an existing thread than create a new thread Allows the number of threads in the application(s) to be bound to the size of the pool
  • 21. 4.21 Silberschatz, Galvin and GagneOperating System Concepts Thread Specific DataThread Specific Data Allows each thread to have its own copy of data Useful when you do not have control over the thread creation process (i.e., when using a thread pool)
  • 22. 4.22 Silberschatz, Galvin and GagneOperating System Concepts Scheduler ActivationsScheduler Activations Both M:M and Two-level models require communication to maintain the appropriate number of kernel threads allocated to the application Scheduler activations provide upcalls - a communication mechanism from the kernel to the thread library This communication allows an application to maintain the correct number kernel threads
  • 23. 4.23 Silberschatz, Galvin and GagneOperating System Concepts PthreadsPthreads 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 (Solaris, Linux, Mac OS X)
  • 24. 4.24 Silberschatz, Galvin and GagneOperating System Concepts Windows XP ThreadsWindows XP Threads Implements the one-to-one mapping Each thread contains A thread id Register set Separate user and kernel stacks Private data storage area The register set, stacks, and private storage area are known as the context of the threads The primary data structures of a thread include: ETHREAD (executive thread block) KTHREAD (kernel thread block) TEB (thread environment block)
  • 25. 4.25 Silberschatz, Galvin and GagneOperating System Concepts Linux ThreadsLinux 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)
  • 26. 4.26 Silberschatz, Galvin and GagneOperating System Concepts Java ThreadsJava Threads Java threads are managed by the JVM Java threads may be created by: Extending Thread class Implementing the Runnable interface
  • 27. 4.27 Silberschatz, Galvin and GagneOperating System Concepts Java Thread StatesJava Thread States
  • 28. End of Chapter 4End of Chapter 4