SlideShare a Scribd company logo
1 of 13
Operating System
THREADS
Presented By:
SHIVAM SINGH
M.Tech
What Is Thread..?
• Thread is a Light Weight
Process.
• Each thread has its own stack,
PC, registers
− Share address space, files,…
PC
PC
PC
Files i/o
stacks
Gigabyte
Virtual
Address
Types of Threads
User Level
Thread (ULT) Kernel Level
Thread (KLT)
User-LevelThreads(ULTs)
Introduction
Thread management done
by user-level threads
library.
Three primary thread
libraries:
• POSIX Pthreads
• Win32 threads
• Java threads
Thread switching
does not require
kernel mode
privileges (no
mode switches)
Scheduling can
be application
specific
ULTs can run
on any OS
Disadvantages of ULTs
 In a typical OS many system calls are blocking.
 As a result, when a ULT executes a system call, not only
is that thread blocked, but all of the threads within the
process are blocked.
 In a pure ULT strategy, a multithreaded application cannot take
advantage of multiprocessing.
Overcoming ULT Disadvantages
Jacketing
• Converts a blocking system call into a non-
blocking system call.
Writing an application as multiple processes rather than
multiple threads.
Kernel-LevelThreads(KLTs)
Introduction
 Thread management is
done by the kernel (could
call them KMT)
• No thread management is
done by the application
• Windows is an example of
this approach
Advantages of KLTs
 The kernel can simultaneously schedule multiple threads from
the same process on multiple processors
 If one thread in a process is blocked, the kernel can schedule
another thread of the same process
Disadvantages of KLTs
 The transfer of control from one thread to another within
the same process requires a mode switch to the kernel
Operation User Level
Thread
Kernel Level
Thread
Processes
Null Fork
Signal Wait
34
37
948
441
11,300
1,840
Thread and Process Operation Latencies(µs)
Benefits of Threads
Takes less
time to
create a new
thread than a
process
Less time to
terminate a
thread than a
process
Switching
between two
threads takes less
time than
switching
between
processes
Threads enhance
efficiency in
communication
between programs
Summary
• User-level Threads
– created and managed by a threads library that runs in the user space
of a process
– a mode switch is not required to switch from one thread to another
– only a single user-level thread within a process can execute at a
time
– if one thread blocks, the entire process is blocked
• Kernel-level Threads
– threads within a process that are maintained by the kernel
– a mode switch is required to switch from one thread to another
– multiple threads within the same process can execute in parallel on
a multiprocessor
– blocking of a thread does not block the entire process
Thank You..!!

More Related Content

What's hot

Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating systemSara Ali
 
Multiprocessor Systems
Multiprocessor SystemsMultiprocessor Systems
Multiprocessor Systemsvampugani
 
14 relationship between processes
14 relationship between processes14 relationship between processes
14 relationship between processesmyrajendra
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating SystemsNitish Gulati
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
cpu scheduling
cpu schedulingcpu scheduling
cpu schedulinghashim102
 
Multi threading
Multi threadingMulti threading
Multi threadinggndu
 
parallel Questions & answers
parallel Questions & answersparallel Questions & answers
parallel Questions & answersMd. Mashiur Rahman
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process ConceptsMukesh Chinta
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-SystemsVenkata Sreeram
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating systemPrankit Mishra
 
Unit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - ThreadsUnit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - Threadscscarcas
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresVaibhav Khanna
 

What's hot (20)

Thread
ThreadThread
Thread
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Multiprocessor Systems
Multiprocessor SystemsMultiprocessor Systems
Multiprocessor Systems
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
14 relationship between processes
14 relationship between processes14 relationship between processes
14 relationship between processes
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 
Thread scheduling in Operating Systems
Thread scheduling in Operating SystemsThread scheduling in Operating Systems
Thread scheduling in Operating Systems
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
cpu scheduling
cpu schedulingcpu scheduling
cpu scheduling
 
Multi threading
Multi threadingMulti threading
Multi threading
 
parallel Questions & answers
parallel Questions & answersparallel Questions & answers
parallel Questions & answers
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Desktop and multiprocessor systems
Desktop and multiprocessor systemsDesktop and multiprocessor systems
Desktop and multiprocessor systems
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating system
 
Unit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - ThreadsUnit II - 2 - Operating System - Threads
Unit II - 2 - Operating System - Threads
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
 

Similar to Threads

Similar to Threads (20)

THREADS of Operating System by Noman Zahid
THREADS of Operating System by Noman Zahid THREADS of Operating System by Noman Zahid
THREADS of Operating System by Noman Zahid
 
Lecture 3 threads
Lecture 3   threadsLecture 3   threads
Lecture 3 threads
 
Thread
ThreadThread
Thread
 
Thread
ThreadThread
Thread
 
Threads.ppt
Threads.pptThreads.ppt
Threads.ppt
 
threads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptxthreads-ppfldkgsh;reghuiregiuhrughet.pptx
threads-ppfldkgsh;reghuiregiuhrughet.pptx
 
Threads
ThreadsThreads
Threads
 
thread os.pptx
thread os.pptxthread os.pptx
thread os.pptx
 
Threads
ThreadsThreads
Threads
 
Thread
ThreadThread
Thread
 
Hardware Multithreading.pdf
Hardware Multithreading.pdfHardware Multithreading.pdf
Hardware Multithreading.pdf
 
Operating system 20 threads
Operating system 20 threadsOperating system 20 threads
Operating system 20 threads
 
chapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.pptchapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.ppt
 
process and thread.pptx
process and thread.pptxprocess and thread.pptx
process and thread.pptx
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3Parallel and Distributed Computing chapter 3
Parallel and Distributed Computing chapter 3
 
Thread
ThreadThread
Thread
 
4 threads
4 threads4 threads
4 threads
 
Ch4 threads
Ch4   threadsCh4   threads
Ch4 threads
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentation
 

More from Shivam Singh

Wpa2 psk security measure
Wpa2 psk security measureWpa2 psk security measure
Wpa2 psk security measureShivam Singh
 
The problems of syrian refugees and european union
The problems of syrian refugees and european unionThe problems of syrian refugees and european union
The problems of syrian refugees and european unionShivam Singh
 
Lightweight cryptography
Lightweight cryptographyLightweight cryptography
Lightweight cryptographyShivam Singh
 
Homomorphic encryption in_cloud
Homomorphic encryption in_cloudHomomorphic encryption in_cloud
Homomorphic encryption in_cloudShivam Singh
 
Enhancing security in cloud storage
Enhancing security in cloud storageEnhancing security in cloud storage
Enhancing security in cloud storageShivam Singh
 
Democracy is mobocracy in india
Democracy is mobocracy in indiaDemocracy is mobocracy in india
Democracy is mobocracy in indiaShivam Singh
 
Data security in cloud environment
Data security in cloud environmentData security in cloud environment
Data security in cloud environmentShivam Singh
 

More from Shivam Singh (11)

Wpa2 psk security measure
Wpa2 psk security measureWpa2 psk security measure
Wpa2 psk security measure
 
Virtualization
VirtualizationVirtualization
Virtualization
 
The problems of syrian refugees and european union
The problems of syrian refugees and european unionThe problems of syrian refugees and european union
The problems of syrian refugees and european union
 
Lightweight cryptography
Lightweight cryptographyLightweight cryptography
Lightweight cryptography
 
I pv6 mechanism
I pv6 mechanismI pv6 mechanism
I pv6 mechanism
 
Homomorphic encryption in_cloud
Homomorphic encryption in_cloudHomomorphic encryption in_cloud
Homomorphic encryption in_cloud
 
Enhancing security in cloud storage
Enhancing security in cloud storageEnhancing security in cloud storage
Enhancing security in cloud storage
 
Democracy is mobocracy in india
Democracy is mobocracy in indiaDemocracy is mobocracy in india
Democracy is mobocracy in india
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Data security in cloud environment
Data security in cloud environmentData security in cloud environment
Data security in cloud environment
 
Url manipulation
Url manipulationUrl manipulation
Url manipulation
 

Recently uploaded

Micro-Choices, Max Impact Personalizing Your Journey, One Moment at a Time.pdf
Micro-Choices, Max Impact Personalizing Your Journey, One Moment at a Time.pdfMicro-Choices, Max Impact Personalizing Your Journey, One Moment at a Time.pdf
Micro-Choices, Max Impact Personalizing Your Journey, One Moment at a Time.pdfPiyush Kumar
 
VIP Call Girls Dongri WhatsApp +91-9833363713, Full Night Service
VIP Call Girls Dongri WhatsApp +91-9833363713, Full Night ServiceVIP Call Girls Dongri WhatsApp +91-9833363713, Full Night Service
VIP Call Girls Dongri WhatsApp +91-9833363713, Full Night Servicemeghakumariji156
 
Social media, ppt. Features, characteristics
Social media, ppt. Features, characteristicsSocial media, ppt. Features, characteristics
Social media, ppt. Features, characteristicswasim792942
 
W.H.Bender Quote 61 -Influential restaurant and food service industry network...
W.H.Bender Quote 61 -Influential restaurant and food service industry network...W.H.Bender Quote 61 -Influential restaurant and food service industry network...
W.H.Bender Quote 61 -Influential restaurant and food service industry network...William (Bill) H. Bender, FCSI
 
Digital-Marketing-Into-by-Zoraiz-Ahmad.pptx
Digital-Marketing-Into-by-Zoraiz-Ahmad.pptxDigital-Marketing-Into-by-Zoraiz-Ahmad.pptx
Digital-Marketing-Into-by-Zoraiz-Ahmad.pptxZACGaming
 
Instant Digital Issuance: An Overview With Critical First Touch Best Practices
Instant Digital Issuance: An Overview With Critical First Touch Best PracticesInstant Digital Issuance: An Overview With Critical First Touch Best Practices
Instant Digital Issuance: An Overview With Critical First Touch Best PracticesMedia Logic
 
Distribution Ad Platform_ The Role of Distribution Ad Network.pdf
Distribution Ad Platform_ The Role of  Distribution Ad Network.pdfDistribution Ad Platform_ The Role of  Distribution Ad Network.pdf
Distribution Ad Platform_ The Role of Distribution Ad Network.pdfTransports Advertising
 
Analysis of Sineing Website and how to fix
Analysis of Sineing Website and how to fixAnalysis of Sineing Website and how to fix
Analysis of Sineing Website and how to fixDHARMENDER PRATAP
 
Enhancing Business Visibility PR Firms in San Francisco
Enhancing Business Visibility PR Firms in San FranciscoEnhancing Business Visibility PR Firms in San Francisco
Enhancing Business Visibility PR Firms in San Franciscosanfranciscoprfirms
 
Discover Ardency Elite: Elevate Your Lifestyle
Discover Ardency Elite: Elevate Your LifestyleDiscover Ardency Elite: Elevate Your Lifestyle
Discover Ardency Elite: Elevate Your LifestyleMy Heart Throw Pillow
 
Brand experience Peoria City Soccer Presentation.pdf
Brand experience Peoria City Soccer Presentation.pdfBrand experience Peoria City Soccer Presentation.pdf
Brand experience Peoria City Soccer Presentation.pdftbatkhuu1
 
What is Google Search Console and What is it provide?
What is Google Search Console and What is it provide?What is Google Search Console and What is it provide?
What is Google Search Console and What is it provide?riteshhsociall
 
BDSM⚡Call Girls in Sector 19 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 19 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 19 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 19 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
Unraveling the Mystery of The Circleville Letters.pptx
Unraveling the Mystery of The Circleville Letters.pptxUnraveling the Mystery of The Circleville Letters.pptx
Unraveling the Mystery of The Circleville Letters.pptxelizabethella096
 
Martal Group - B2B Lead Gen Agency - Onboarding Overview
Martal Group - B2B Lead Gen Agency - Onboarding OverviewMartal Group - B2B Lead Gen Agency - Onboarding Overview
Martal Group - B2B Lead Gen Agency - Onboarding OverviewMartal Group
 
How consumers use technology and the impacts on their lives
How consumers use technology and the impacts on their livesHow consumers use technology and the impacts on their lives
How consumers use technology and the impacts on their livesMathuraa
 
Situation Analysis | Management Company.
Situation Analysis | Management Company.Situation Analysis | Management Company.
Situation Analysis | Management Company.DanielaQuiroz63
 
[Expert Panel] New Google Shopping Ads Strategies Uncovered
[Expert Panel] New Google Shopping Ads Strategies Uncovered[Expert Panel] New Google Shopping Ads Strategies Uncovered
[Expert Panel] New Google Shopping Ads Strategies UncoveredSearch Engine Journal
 
Five Essential Tools for International SEO - Natalia Witczyk - SearchNorwich 15
Five Essential Tools for International SEO - Natalia Witczyk - SearchNorwich 15Five Essential Tools for International SEO - Natalia Witczyk - SearchNorwich 15
Five Essential Tools for International SEO - Natalia Witczyk - SearchNorwich 15SearchNorwich
 

Recently uploaded (20)

Micro-Choices, Max Impact Personalizing Your Journey, One Moment at a Time.pdf
Micro-Choices, Max Impact Personalizing Your Journey, One Moment at a Time.pdfMicro-Choices, Max Impact Personalizing Your Journey, One Moment at a Time.pdf
Micro-Choices, Max Impact Personalizing Your Journey, One Moment at a Time.pdf
 
VIP Call Girls Dongri WhatsApp +91-9833363713, Full Night Service
VIP Call Girls Dongri WhatsApp +91-9833363713, Full Night ServiceVIP Call Girls Dongri WhatsApp +91-9833363713, Full Night Service
VIP Call Girls Dongri WhatsApp +91-9833363713, Full Night Service
 
Social media, ppt. Features, characteristics
Social media, ppt. Features, characteristicsSocial media, ppt. Features, characteristics
Social media, ppt. Features, characteristics
 
W.H.Bender Quote 61 -Influential restaurant and food service industry network...
W.H.Bender Quote 61 -Influential restaurant and food service industry network...W.H.Bender Quote 61 -Influential restaurant and food service industry network...
W.H.Bender Quote 61 -Influential restaurant and food service industry network...
 
Digital-Marketing-Into-by-Zoraiz-Ahmad.pptx
Digital-Marketing-Into-by-Zoraiz-Ahmad.pptxDigital-Marketing-Into-by-Zoraiz-Ahmad.pptx
Digital-Marketing-Into-by-Zoraiz-Ahmad.pptx
 
Instant Digital Issuance: An Overview With Critical First Touch Best Practices
Instant Digital Issuance: An Overview With Critical First Touch Best PracticesInstant Digital Issuance: An Overview With Critical First Touch Best Practices
Instant Digital Issuance: An Overview With Critical First Touch Best Practices
 
Distribution Ad Platform_ The Role of Distribution Ad Network.pdf
Distribution Ad Platform_ The Role of  Distribution Ad Network.pdfDistribution Ad Platform_ The Role of  Distribution Ad Network.pdf
Distribution Ad Platform_ The Role of Distribution Ad Network.pdf
 
Analysis of Sineing Website and how to fix
Analysis of Sineing Website and how to fixAnalysis of Sineing Website and how to fix
Analysis of Sineing Website and how to fix
 
Enhancing Business Visibility PR Firms in San Francisco
Enhancing Business Visibility PR Firms in San FranciscoEnhancing Business Visibility PR Firms in San Francisco
Enhancing Business Visibility PR Firms in San Francisco
 
Discover Ardency Elite: Elevate Your Lifestyle
Discover Ardency Elite: Elevate Your LifestyleDiscover Ardency Elite: Elevate Your Lifestyle
Discover Ardency Elite: Elevate Your Lifestyle
 
Brand experience Peoria City Soccer Presentation.pdf
Brand experience Peoria City Soccer Presentation.pdfBrand experience Peoria City Soccer Presentation.pdf
Brand experience Peoria City Soccer Presentation.pdf
 
What is Google Search Console and What is it provide?
What is Google Search Console and What is it provide?What is Google Search Console and What is it provide?
What is Google Search Console and What is it provide?
 
BDSM⚡Call Girls in Sector 19 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 19 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 19 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 19 Noida Escorts >༒8448380779 Escort Service
 
Unraveling the Mystery of The Circleville Letters.pptx
Unraveling the Mystery of The Circleville Letters.pptxUnraveling the Mystery of The Circleville Letters.pptx
Unraveling the Mystery of The Circleville Letters.pptx
 
Buy Linkedin Sales Navigator at Cheap Price
Buy Linkedin Sales Navigator at Cheap PriceBuy Linkedin Sales Navigator at Cheap Price
Buy Linkedin Sales Navigator at Cheap Price
 
Martal Group - B2B Lead Gen Agency - Onboarding Overview
Martal Group - B2B Lead Gen Agency - Onboarding OverviewMartal Group - B2B Lead Gen Agency - Onboarding Overview
Martal Group - B2B Lead Gen Agency - Onboarding Overview
 
How consumers use technology and the impacts on their lives
How consumers use technology and the impacts on their livesHow consumers use technology and the impacts on their lives
How consumers use technology and the impacts on their lives
 
Situation Analysis | Management Company.
Situation Analysis | Management Company.Situation Analysis | Management Company.
Situation Analysis | Management Company.
 
[Expert Panel] New Google Shopping Ads Strategies Uncovered
[Expert Panel] New Google Shopping Ads Strategies Uncovered[Expert Panel] New Google Shopping Ads Strategies Uncovered
[Expert Panel] New Google Shopping Ads Strategies Uncovered
 
Five Essential Tools for International SEO - Natalia Witczyk - SearchNorwich 15
Five Essential Tools for International SEO - Natalia Witczyk - SearchNorwich 15Five Essential Tools for International SEO - Natalia Witczyk - SearchNorwich 15
Five Essential Tools for International SEO - Natalia Witczyk - SearchNorwich 15
 

Threads

  • 2. What Is Thread..? • Thread is a Light Weight Process. • Each thread has its own stack, PC, registers − Share address space, files,… PC PC PC Files i/o stacks Gigabyte Virtual Address
  • 3. Types of Threads User Level Thread (ULT) Kernel Level Thread (KLT)
  • 4. User-LevelThreads(ULTs) Introduction Thread management done by user-level threads library. Three primary thread libraries: • POSIX Pthreads • Win32 threads • Java threads
  • 5. Thread switching does not require kernel mode privileges (no mode switches) Scheduling can be application specific ULTs can run on any OS
  • 6. Disadvantages of ULTs  In a typical OS many system calls are blocking.  As a result, when a ULT executes a system call, not only is that thread blocked, but all of the threads within the process are blocked.  In a pure ULT strategy, a multithreaded application cannot take advantage of multiprocessing.
  • 7. Overcoming ULT Disadvantages Jacketing • Converts a blocking system call into a non- blocking system call. Writing an application as multiple processes rather than multiple threads.
  • 8. Kernel-LevelThreads(KLTs) Introduction  Thread management is done by the kernel (could call them KMT) • No thread management is done by the application • Windows is an example of this approach
  • 9. Advantages of KLTs  The kernel can simultaneously schedule multiple threads from the same process on multiple processors  If one thread in a process is blocked, the kernel can schedule another thread of the same process
  • 10. Disadvantages of KLTs  The transfer of control from one thread to another within the same process requires a mode switch to the kernel Operation User Level Thread Kernel Level Thread Processes Null Fork Signal Wait 34 37 948 441 11,300 1,840 Thread and Process Operation Latencies(µs)
  • 11. Benefits of Threads Takes less time to create a new thread than a process Less time to terminate a thread than a process Switching between two threads takes less time than switching between processes Threads enhance efficiency in communication between programs
  • 12. Summary • User-level Threads – created and managed by a threads library that runs in the user space of a process – a mode switch is not required to switch from one thread to another – only a single user-level thread within a process can execute at a time – if one thread blocks, the entire process is blocked • Kernel-level Threads – threads within a process that are maintained by the kernel – a mode switch is required to switch from one thread to another – multiple threads within the same process can execute in parallel on a multiprocessor – blocking of a thread does not block the entire process