SlideShare a Scribd company logo
1 of 19
Chapter 4: Threads
4.2 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Introduction
• A thread is a basic unit of CPU utilization; it
comprises a thread ID, a program counter, a
register set, and a stack.
• It shares with other threads belonging to the same
process its code section, data section, and other
operating-system resources, such as open files and
signals.
4.3 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Introduction
• Let's say, for example, a program is not capable of
drawing pictures while reading keystrokes. The
program must give its full attention to the keyboard
input lacking the ability to handle more than one event
at a time.
• The ideal solution to this problem is the seamless
execution of two or more sections of a program at the
same time. Threads allows us to do this.
4.4 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
User Threads
 Mostsoftware applications that run on modern computers are
Multithreaded.
 An application typically is implemented as a separate process with
several threads of control.
 A web browser might have one thread display images or text while another
thread retrieves data from the network, for example.
 A word processor may have a thread for displaying graphics, another
thread for responding to keystrokes from the user, and a third thread for
performing spelling and grammar checking in the background.
4.5 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Kernel Threads
 Finally, most operating-system kernels are now
multithreaded. Several threads operate in the
kernel, and each thread performs a specific
task, such as managing devices, managing
memory, or interrupt handling.
4.6 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Single and Multithreaded Processes
4.7 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Benefits
• Responsiveness– may allow continued execution if part
of process is blocked, especially important for user
interfaces.
• Resource Sharing– threads share resources of process,
easier than shared memory or message passing.
• Economy– cheaper than process creation, thread
switching lower overhead than context switching.
• Scalability– process can take advantage of multiprocessor
architectures.
4.8 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Multicore Programming
• Multithreaded programming provides a mechanism for
more efficient use of these multicore or multiprocessor
systems.
Concurrent execution on single-core system
Parallelism on a multi-core system
4.9 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Multithreading Models
• Support for threads may be provided either at the user
level, for user threads, or by the kernel, for kernel
threads.
• User threads are supported above the kernel and are
managed without kernel support, whereas kernel
threads are supported and managed directly by the
operating system.
4.10 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Multithreading Models
• Ultimately, a relationship must exist between user threads
and kernel threads.
• We look at three common models:
 the one-to-one model,
 the many-to-one model, and
 the many-to-many model.
4.11 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Many-to-One
• Many user-level threads mapped to single kernel thread
• The Drawback is that the entire system will block if a
third makes blocking system call.
• Examples:
• Solaris Green Threads
• GNU Portable Threads
4.12 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Many-to-One Model
4.13 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
One-to-One
• Each user-level thread maps to kernel thread
• The one-to-one model maps each user thread to a
kernel thread. It also allows multiple threads to run in
parallel on multiprocessors.
• Examples
• Windows NT/XP/2000
• Linux
• Solaris 9 and later
4.14 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
One-to-one Model
4.15 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
One-to-One drawback
• The only drawback to this model is that creating a
user thread requires creating the corresponding
kernel thread.
• Because the overhead of creating kernel threads can
burden the performance of an application, most
implementations of this model restrict the number
of threads supported by the system.
• Linux, along with the family of Windows
operating systems, implement the one-to-one
model.
4.16 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Many-to-Many Model
• Allows many user level threads to be mapped to many
kernel threads
• Allows the operating system to create a sufficient
number of kernel threads
• Allows the developer to create as many user threads as
she wishes, it does not result in true concurrency,
because the kernel can schedule only one thread at a
time.
• Examples
• Solaris prior to version 9
• Windows NT/2000 with the ThreadFiber package
4.17 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Many-to-Many Model
4.18 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Two-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.19 Silberschatz, Galvin and Gagne ©2005
Operating System Concepts
Two-level Model

More Related Content

Similar to OS-operating systems- ch04 (Threads) ...

Similar to OS-operating systems- ch04 (Threads) ... (20)

ch4.ppt
ch4.pptch4.ppt
ch4.ppt
 
Threads semaphoremutexlocksdeadlockp.ppt
Threads semaphoremutexlocksdeadlockp.pptThreads semaphoremutexlocksdeadlockp.ppt
Threads semaphoremutexlocksdeadlockp.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
 
ch4.ppt
ch4.pptch4.ppt
ch4.ppt
 
Thread
ThreadThread
Thread
 
W-9.pptx
W-9.pptxW-9.pptx
W-9.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"
 
Ch4 threads
Ch4 threadsCh4 threads
Ch4 threads
 
Thread (Operating System)
Thread  (Operating System)Thread  (Operating System)
Thread (Operating System)
 
My DIaries
My DIariesMy DIaries
My DIaries
 
Lecture 3 threads
Lecture 3   threadsLecture 3   threads
Lecture 3 threads
 
Concept of thread
Concept of threadConcept of thread
Concept of thread
 
Operating system 20 threads
Operating system 20 threadsOperating system 20 threads
Operating system 20 threads
 
Michael snowhite1
Michael snowhite1Michael snowhite1
Michael snowhite1
 
Clifford sugerman
Clifford sugermanClifford sugerman
Clifford sugerman
 
Epc 3.ppt
Epc 3.pptEpc 3.ppt
Epc 3.ppt
 
15 threads
15 threads15 threads
15 threads
 
Architecture of web servers
Architecture of web serversArchitecture of web servers
Architecture of web servers
 
z13: New Opportunities – if you dare!
z13: New Opportunities – if you dare!z13: New Opportunities – if you dare!
z13: New Opportunities – if you dare!
 
Red Hat for IBM System z IBM Enterprise2014 Las Vegas
Red Hat for IBM System z IBM Enterprise2014 Las Vegas Red Hat for IBM System z IBM Enterprise2014 Las Vegas
Red Hat for IBM System z IBM Enterprise2014 Las Vegas
 

More from Dr. Mazin Mohamed alkathiri

ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)Dr. Mazin Mohamed alkathiri
 
Advance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-BAdvance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-BDr. Mazin Mohamed alkathiri
 
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)Dr. Mazin Mohamed alkathiri
 
Academic Writing (Technical report writing ) class 07
Academic Writing (Technical report writing ) class 07Academic Writing (Technical report writing ) class 07
Academic Writing (Technical report writing ) class 07Dr. Mazin Mohamed alkathiri
 

More from Dr. Mazin Mohamed alkathiri (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Advance Mobile Application Development class 05
Advance Mobile Application Development class 05Advance Mobile Application Development class 05
Advance Mobile Application Development class 05
 
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
ESSENTIAL of (CS/IT/IS) class 05 (Software concepts)
 
OS-operating systems- ch03
OS-operating systems- ch03OS-operating systems- ch03
OS-operating systems- ch03
 
OS-operating systems - ch02 - part-2-2024
OS-operating systems - ch02 - part-2-2024OS-operating systems - ch02 - part-2-2024
OS-operating systems - ch02 - part-2-2024
 
Advance Mobile Application Development class 04
Advance Mobile Application Development class 04Advance Mobile Application Development class 04
Advance Mobile Application Development class 04
 
Advance Mobile Application Development class 03
Advance Mobile Application Development class 03Advance Mobile Application Development class 03
Advance Mobile Application Development class 03
 
Advance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-BAdvance Mobile Application Development class 02-B
Advance Mobile Application Development class 02-B
 
OS-ch02-part-1-2024.ppt
OS-ch02-part-1-2024.pptOS-ch02-part-1-2024.ppt
OS-ch02-part-1-2024.ppt
 
Advance Mobile Application Development class 02
Advance Mobile Application Development class 02Advance Mobile Application Development class 02
Advance Mobile Application Development class 02
 
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
ESSENTIAL of (CS/IT/IS) class 03-04 (NUMERIC SYSTEMS)
 
Advance Mobile Application Development class 01
Advance Mobile Application Development class 01Advance Mobile Application Development class 01
Advance Mobile Application Development class 01
 
ESSENTIAL of (CS/IT/IS) class 02 (HCI)
ESSENTIAL of (CS/IT/IS) class 02 (HCI)ESSENTIAL of (CS/IT/IS) class 02 (HCI)
ESSENTIAL of (CS/IT/IS) class 02 (HCI)
 
Seminar
SeminarSeminar
Seminar
 
ESSENTIAL of (CS/IT/IS)
ESSENTIAL of (CS/IT/IS)ESSENTIAL of (CS/IT/IS)
ESSENTIAL of (CS/IT/IS)
 
OS-ch01-2024.ppt
OS-ch01-2024.pptOS-ch01-2024.ppt
OS-ch01-2024.ppt
 
Mobile Application Development class 008
Mobile Application Development class 008Mobile Application Development class 008
Mobile Application Development class 008
 
Academic Writing (Punctuation ) class 06
Academic Writing (Punctuation ) class 06Academic Writing (Punctuation ) class 06
Academic Writing (Punctuation ) class 06
 
Academic Writing (Technical report writing ) class 07
Academic Writing (Technical report writing ) class 07Academic Writing (Technical report writing ) class 07
Academic Writing (Technical report writing ) class 07
 

Recently uploaded

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 

Recently uploaded (20)

Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 

OS-operating systems- ch04 (Threads) ...

  • 2. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Introduction • A thread is a basic unit of CPU utilization; it comprises a thread ID, a program counter, a register set, and a stack. • It shares with other threads belonging to the same process its code section, data section, and other operating-system resources, such as open files and signals.
  • 3. 4.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Introduction • Let's say, for example, a program is not capable of drawing pictures while reading keystrokes. The program must give its full attention to the keyboard input lacking the ability to handle more than one event at a time. • The ideal solution to this problem is the seamless execution of two or more sections of a program at the same time. Threads allows us to do this.
  • 4. 4.4 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts User Threads  Mostsoftware applications that run on modern computers are Multithreaded.  An application typically is implemented as a separate process with several threads of control.  A web browser might have one thread display images or text while another thread retrieves data from the network, for example.  A word processor may have a thread for displaying graphics, another thread for responding to keystrokes from the user, and a third thread for performing spelling and grammar checking in the background.
  • 5. 4.5 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Kernel Threads  Finally, most operating-system kernels are now multithreaded. Several threads operate in the kernel, and each thread performs a specific task, such as managing devices, managing memory, or interrupt handling.
  • 6. 4.6 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Single and Multithreaded Processes
  • 7. 4.7 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Benefits • Responsiveness– may allow continued execution if part of process is blocked, especially important for user interfaces. • Resource Sharing– threads share resources of process, easier than shared memory or message passing. • Economy– cheaper than process creation, thread switching lower overhead than context switching. • Scalability– process can take advantage of multiprocessor architectures.
  • 8. 4.8 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Multicore Programming • Multithreaded programming provides a mechanism for more efficient use of these multicore or multiprocessor systems. Concurrent execution on single-core system Parallelism on a multi-core system
  • 9. 4.9 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Multithreading Models • Support for threads may be provided either at the user level, for user threads, or by the kernel, for kernel threads. • User threads are supported above the kernel and are managed without kernel support, whereas kernel threads are supported and managed directly by the operating system.
  • 10. 4.10 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Multithreading Models • Ultimately, a relationship must exist between user threads and kernel threads. • We look at three common models:  the one-to-one model,  the many-to-one model, and  the many-to-many model.
  • 11. 4.11 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Many-to-One • Many user-level threads mapped to single kernel thread • The Drawback is that the entire system will block if a third makes blocking system call. • Examples: • Solaris Green Threads • GNU Portable Threads
  • 12. 4.12 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Many-to-One Model
  • 13. 4.13 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts One-to-One • Each user-level thread maps to kernel thread • The one-to-one model maps each user thread to a kernel thread. It also allows multiple threads to run in parallel on multiprocessors. • Examples • Windows NT/XP/2000 • Linux • Solaris 9 and later
  • 14. 4.14 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts One-to-one Model
  • 15. 4.15 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts One-to-One drawback • The only drawback to this model is that creating a user thread requires creating the corresponding kernel thread. • Because the overhead of creating kernel threads can burden the performance of an application, most implementations of this model restrict the number of threads supported by the system. • Linux, along with the family of Windows operating systems, implement the one-to-one model.
  • 16. 4.16 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Many-to-Many Model • Allows many user level threads to be mapped to many kernel threads • Allows the operating system to create a sufficient number of kernel threads • Allows the developer to create as many user threads as she wishes, it does not result in true concurrency, because the kernel can schedule only one thread at a time. • Examples • Solaris prior to version 9 • Windows NT/2000 with the ThreadFiber package
  • 17. 4.17 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Many-to-Many Model
  • 18. 4.18 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Two-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
  • 19. 4.19 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Two-level Model