SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
OPERATING SYSTEMS

     Threads


    Jerry Breecher


        4: Threads   1
OPERATING SYSTEM
             Threads
         What Is In This Chapter?
Overview
Multithreading Models
Threading Issues
Pthreads
Windows XP Threads
Linux Threads
Java Threads


                        4: Threads   2
Single and
THREADS                Multithreaded
                        Processes




          4: Threads              3
Benefits
THREADS

Responsiveness

Resource Sharing

Economy

Utilization of MP Architectures




                      4: Threads              4
THREADS                                       User Threads
Thread management done by user-level threads library

Examples
- POSIX Pthreads
- Mach C-threads
- Solaris threads

 Supported by the Kernel
                                            Kernel Threads
 Examples
 - Windows 95/98/NT/2000
 - Solaris
 - Tru64 UNIX
 - BeOS
 - Linux                   4: Threads                   5
Multithreading
THREADS                               Models


Many-to-One

                            How do user and kernel
One-to-One                  threads map into each other?


Many-to-Many




               4: Threads                              6
THREADS                             Many-to-One


Many user-level threads
mapped to single kernel
thread.

Used on systems that
do not support kernel
threads.
Examples:
 Solaris Green Threads
 GNU Portable Threads




                          4: Threads           7
THREADS                                      One-to-One
Each user-level thread maps to kernel thread.

Examples
- Windows 95/98/NT/2000
- Linux




                             4: Threads                8
Threading Issues
    THREADS
Semantics of fork() and exec() system calls
  Does fork() duplicate only the calling thread or all threads?

Thread 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: Threads                         9
Threading Issues
     THREADS
Signal 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
Thread 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: Threads                                10
Threading Issues
   THREADS
Thread 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)

Scheduler activations
  Many:Many 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: Threads                         11
THREADS                        Various Implementations
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 (Solaris, Linux, Mac OS X)

Windows 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
                                 4: Threads                          12
THREADS                            Various Implementations
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)

Java Threads
   Java threads may be created by:
      Extending Thread class
      Implementing the Runnable interface
   Java threads are managed by the JVM.




                                     4: Threads                               13
Threads
                           WRAPUP

We’ve looked in detail at how threads work. Specifically we’ve looked
at:

Multithreading Models
Threading Issues
Pthreads
Windows XP Threads
Linux Threads
Java Threads




                             4: Threads                        14

Contenu connexe

Tendances

Operating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - ThreadsOperating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - ThreadsPeter Tröger
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingguesta40f80
 
multi-threading
multi-threadingmulti-threading
multi-threadingEzzat Gul
 
Thread management
Thread management Thread management
Thread management Ayaan Adeel
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)Nagarajan
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-GalvinSonali Chauhan
 
Lecture 9 -_pthreads-linux_threads
Lecture 9 -_pthreads-linux_threadsLecture 9 -_pthreads-linux_threads
Lecture 9 -_pthreads-linux_threadsPrashant Pawar
 
Thread (Operating System)
Thread  (Operating System)Thread  (Operating System)
Thread (Operating System)kiran Patel
 
Networking threads
Networking threadsNetworking threads
Networking threadsNilesh Pawar
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programmingAnyapuPranav
 
Multithreading
MultithreadingMultithreading
MultithreadingA B Shinde
 
Threads and multi threading
Threads and multi threadingThreads and multi threading
Threads and multi threadingAntonio Cesarano
 
Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)sonuu__
 
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 noman zahid
 

Tendances (20)

Operating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - ThreadsOperating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - Threads
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programming
 
Thread
ThreadThread
Thread
 
4 threads
4 threads4 threads
4 threads
 
multi-threading
multi-threadingmulti-threading
multi-threading
 
Thread management
Thread management Thread management
Thread management
 
Posix threads(asha)
Posix threads(asha)Posix threads(asha)
Posix threads(asha)
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
 
OSCh5
OSCh5OSCh5
OSCh5
 
Lecture 9 -_pthreads-linux_threads
Lecture 9 -_pthreads-linux_threadsLecture 9 -_pthreads-linux_threads
Lecture 9 -_pthreads-linux_threads
 
Treads
TreadsTreads
Treads
 
Thread (Operating System)
Thread  (Operating System)Thread  (Operating System)
Thread (Operating System)
 
Networking threads
Networking threadsNetworking threads
Networking threads
 
Multi threaded programming
Multi threaded programmingMulti threaded programming
Multi threaded programming
 
Threads
ThreadsThreads
Threads
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Threads and multi threading
Threads and multi threadingThreads and multi threading
Threads and multi threading
 
Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)Operating system: threads(mulithreading,benefits of threads, types of thread)
Operating system: threads(mulithreading,benefits of threads, types of thread)
 
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
 

En vedette

ใบงานที่ 3 ขอบข่ายและประเภทของโครงงาน
ใบงานที่ 3 ขอบข่ายและประเภทของโครงงานใบงานที่ 3 ขอบข่ายและประเภทของโครงงาน
ใบงานที่ 3 ขอบข่ายและประเภทของโครงงานNet'Net Zii
 
Aros Mini MBA - infomateriale om lederuddannelsen (minimba)
Aros Mini MBA - infomateriale om lederuddannelsen (minimba)Aros Mini MBA - infomateriale om lederuddannelsen (minimba)
Aros Mini MBA - infomateriale om lederuddannelsen (minimba)Anders Rosenlund
 
Networked Dynamic Systems: Identification, Controllability, and Randomness
Networked Dynamic Systems: Identification, Controllability, and RandomnessNetworked Dynamic Systems: Identification, Controllability, and Randomness
Networked Dynamic Systems: Identification, Controllability, and RandomnessMarzieh Nabi
 
Butterfly
ButterflyButterfly
Butterflyvenuavs
 
Making Infrastructure as Awesome as Agile Development
Making Infrastructure as Awesome as Agile DevelopmentMaking Infrastructure as Awesome as Agile Development
Making Infrastructure as Awesome as Agile Developmentmsilpala
 
Pdf 1 presentacion 22-03-13 scdad eh
Pdf 1 presentacion 22-03-13 scdad ehPdf 1 presentacion 22-03-13 scdad eh
Pdf 1 presentacion 22-03-13 scdad eheuskalemfyre
 
Network Identification via Node Knock-out
Network Identification via Node Knock-outNetwork Identification via Node Knock-out
Network Identification via Node Knock-outMarzieh Nabi
 
愛的承諾Apo 2010年版com99080204
愛的承諾Apo 2010年版com99080204愛的承諾Apo 2010年版com99080204
愛的承諾Apo 2010年版com99080204惠燕 蔡
 
Marta medina cv
Marta medina cvMarta medina cv
Marta medina cvChinmayo
 

En vedette (20)

ใบงานที่ 3 ขอบข่ายและประเภทของโครงงาน
ใบงานที่ 3 ขอบข่ายและประเภทของโครงงานใบงานที่ 3 ขอบข่ายและประเภทของโครงงาน
ใบงานที่ 3 ขอบข่ายและประเภทของโครงงาน
 
QReequn presentation
QReequn presentationQReequn presentation
QReequn presentation
 
Aros Mini MBA - infomateriale om lederuddannelsen (minimba)
Aros Mini MBA - infomateriale om lederuddannelsen (minimba)Aros Mini MBA - infomateriale om lederuddannelsen (minimba)
Aros Mini MBA - infomateriale om lederuddannelsen (minimba)
 
Networked Dynamic Systems: Identification, Controllability, and Randomness
Networked Dynamic Systems: Identification, Controllability, and RandomnessNetworked Dynamic Systems: Identification, Controllability, and Randomness
Networked Dynamic Systems: Identification, Controllability, and Randomness
 
Butterfly
ButterflyButterfly
Butterfly
 
Making Infrastructure as Awesome as Agile Development
Making Infrastructure as Awesome as Agile DevelopmentMaking Infrastructure as Awesome as Agile Development
Making Infrastructure as Awesome as Agile Development
 
6 матем
6 матем6 матем
6 матем
 
Por qué seguimos leyendo
Por qué seguimos leyendoPor qué seguimos leyendo
Por qué seguimos leyendo
 
Pdf 1 presentacion 22-03-13 scdad eh
Pdf 1 presentacion 22-03-13 scdad ehPdf 1 presentacion 22-03-13 scdad eh
Pdf 1 presentacion 22-03-13 scdad eh
 
Network Identification via Node Knock-out
Network Identification via Node Knock-outNetwork Identification via Node Knock-out
Network Identification via Node Knock-out
 
PIEAS
PIEASPIEAS
PIEAS
 
ISEA Paper 2011
ISEA Paper 2011ISEA Paper 2011
ISEA Paper 2011
 
Presentation1
Presentation1Presentation1
Presentation1
 
愛的承諾Apo 2010年版com99080204
愛的承諾Apo 2010年版com99080204愛的承諾Apo 2010年版com99080204
愛的承諾Apo 2010年版com99080204
 
Energofor
EnergoforEnergofor
Energofor
 
Daniel
DanielDaniel
Daniel
 
Business Modelling
Business ModellingBusiness Modelling
Business Modelling
 
MY POTFOLIO
MY POTFOLIOMY POTFOLIO
MY POTFOLIO
 
SHLOMO - VOL.2 - September 2012
SHLOMO - VOL.2 - September 2012 SHLOMO - VOL.2 - September 2012
SHLOMO - VOL.2 - September 2012
 
Marta medina cv
Marta medina cvMarta medina cv
Marta medina cv
 

Similaire à Section04 threads

Similaire à Section04 threads (20)

Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
4.Threads
4.Threads4.Threads
4.Threads
 
CH04.pdf
CH04.pdfCH04.pdf
CH04.pdf
 
Ch04 threads
Ch04 threadsCh04 threads
Ch04 threads
 
Ch4 threads
Ch4   threadsCh4   threads
Ch4 threads
 
Sucet os module_2_notes
Sucet os module_2_notesSucet os module_2_notes
Sucet os module_2_notes
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
15 threads
15 threads15 threads
15 threads
 
Lecture 3- Threads (1).pptx
Lecture 3- Threads (1).pptxLecture 3- Threads (1).pptx
Lecture 3- Threads (1).pptx
 
Chapter04 new
Chapter04 newChapter04 new
Chapter04 new
 
Threading.pptx
Threading.pptxThreading.pptx
Threading.pptx
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
 
4.Process.ppt
4.Process.ppt4.Process.ppt
4.Process.ppt
 
Thread
ThreadThread
Thread
 
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptxWEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
 
OS Thr schd.ppt
OS Thr schd.pptOS Thr schd.ppt
OS Thr schd.ppt
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
Operating system 21 multithreading models
Operating system 21 multithreading modelsOperating system 21 multithreading models
Operating system 21 multithreading models
 
My DIaries
My DIariesMy DIaries
My DIaries
 
Threads
ThreadsThreads
Threads
 

Dernier

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Dernier (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Section04 threads

  • 1. OPERATING SYSTEMS Threads Jerry Breecher 4: Threads 1
  • 2. OPERATING SYSTEM Threads What Is In This Chapter? Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads 4: Threads 2
  • 3. Single and THREADS Multithreaded Processes 4: Threads 3
  • 5. THREADS User Threads Thread management done by user-level threads library Examples - POSIX Pthreads - Mach C-threads - Solaris threads Supported by the Kernel Kernel Threads Examples - Windows 95/98/NT/2000 - Solaris - Tru64 UNIX - BeOS - Linux 4: Threads 5
  • 6. Multithreading THREADS Models Many-to-One How do user and kernel One-to-One threads map into each other? Many-to-Many 4: Threads 6
  • 7. THREADS Many-to-One Many user-level threads mapped to single kernel thread. Used on systems that do not support kernel threads. Examples: Solaris Green Threads GNU Portable Threads 4: Threads 7
  • 8. THREADS One-to-One Each user-level thread maps to kernel thread. Examples - Windows 95/98/NT/2000 - Linux 4: Threads 8
  • 9. Threading Issues THREADS Semantics of fork() and exec() system calls Does fork() duplicate only the calling thread or all threads? Thread 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: Threads 9
  • 10. Threading Issues THREADS Signal 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 Thread 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: Threads 10
  • 11. Threading Issues THREADS Thread 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) Scheduler activations Many:Many 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: Threads 11
  • 12. THREADS Various Implementations 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 (Solaris, Linux, Mac OS X) Windows 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 4: Threads 12
  • 13. THREADS Various Implementations 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) Java Threads Java threads may be created by: Extending Thread class Implementing the Runnable interface Java threads are managed by the JVM. 4: Threads 13
  • 14. Threads WRAPUP We’ve looked in detail at how threads work. Specifically we’ve looked at: Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads 4: Threads 14