SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Multi Threading Models
Multithreading models
• There are three dominant models for
thread libraries, each with its own
trade-offs
– many threads on one LWP (many-to-one)
– one thread per LWP (one-to-one)
– many threads on many LWPs (many-to-
many)
• Similar models can apply on
scheduling kernel threads to real CPUs
Many-to-one
• In this model, the library maps all
threads to a single lightweight process
• Advantages:
– totally portable
– easy to do with few systems
dependencies
• Disadvantages:
– cannot take advantage of parallelism
– may have to block for synchronous
I/O
– there is a clever technique for
avoiding it
• Mainly used in language systems,
portable libraries
One-to-one
• In this model, the library maps each
thread to a different lightweight
process
• Advantages:
– can exploit parallelism, blocking
system calls
• Disadvantages:
– thread creation involves LWP
creation
– each thread takes up kernel
resources
– limiting the number of total threads
• Used in LinuxThreads and other
systems where LWP creation is not too
expensive
Many-to-many
• In this model, the library has two
kinds of threads: bound and
unbound
– bound threads are mapped
each to a single lightweight
process
– unbound threads may be
mapped to the same LWP
• Probably the best of both worlds
• Used in the Solaris
implementation of Pthreads (and
several other Unix
implementations)
High-Level Program Structure Ideas
• Boss/workers model
• Pipeline model
• Up-calls
• Keeping shared information consistent
using version stamps
Thread Design Patterns
Common ways of structuring programs using threads
• Boss/workers model
– boss gets assignments, dispatches tasks to workers
– variants (thread pool, single thread per connection…)
• Pipeline model
– do some work, pass partial result to next thread
• Up-calls
– fast control flow transfer for layered systems
• Version stamps
– technique for keeping information consistent
Boss/Workers
Boss: Worker:
forever { taskX();
get a request
switch(request)
case X: Fork (taskX)
case Y: Fork (taskY)
…
}
• Advantage: simplicity
• Disadvantage: bound on number of workers, overheard of
threads creation, contention if requests have
interdependencies
• Variants: fixed thread pool (aka workpile, workqueue),
producer/consumer relationship, workers determine what
needs to be performed…
Pipeline
• Each thread completes portion of a task,
and passes results
• like an assembly line or a processor
pipeline
• Advantages: trivial synchronization,
simplicity
• Disadvantages: limits degree of parallelism,
throughput driven by slowest stage,
handtuning needed
Up-calls
• Layered applications, e.g. network protocol stacks
have top-down and bottom-up flows
• Up-calls is a technique in which you structure layers
so that they can expect calls from below
• Thread pool of specialized threads in each layer
– essentially an up-call pipeline per connection
• Advantages: best when used with fast, synchronous
control flow transfer mechanisms or program
structuring tool
• Disadvantages: programming becomes more
complicated, synchronization required for top-
down
Version Stamps
• (Not a programming structure idea but
useful technique for any kind of distributed
environment)
• Maintain “version number” for shared data
– keep local cached copy of data
– check versions to determine if changed

More Related Content

What's hot (20)

PPT
Swap-space Management
Agnas Jasmine
 
PPTX
Free Space Management, Efficiency & Performance, Recovery and NFS
United International University
 
PPTX
Inter Process Communication
Adeel Rasheed
 
PPTX
System calls
Bernard Senam
 
PDF
operating system structure
Waseem Ud Din Farooqui
 
PDF
Operating system concepts (notes)
Sohaib Danish
 
PPT
Memory management
Vishal Singh
 
PPTX
Page replacement algorithms
Piyush Rochwani
 
PPS
Virtual memory
Anuj Modi
 
PPT
Paging.ppt
infomerlin
 
PPT
Sliding window protocol
Shehara Abeythunga
 
PPTX
Handheld operting system
Aj Maurya
 
PPTX
INSTRUCTION LEVEL PARALLALISM
Kamran Ashraf
 
PPTX
Process scheduling
Riya Choudhary
 
PPTX
Memory management
Muhammad Fayyaz
 
PPT
Operating system services 9
myrajendra
 
PPT
Multi core-architecture
Piyush Mittal
 
PPT
Multiprocessor Systems
vampugani
 
PPTX
Heap Management
Jenny Galino
 
Swap-space Management
Agnas Jasmine
 
Free Space Management, Efficiency & Performance, Recovery and NFS
United International University
 
Inter Process Communication
Adeel Rasheed
 
System calls
Bernard Senam
 
operating system structure
Waseem Ud Din Farooqui
 
Operating system concepts (notes)
Sohaib Danish
 
Memory management
Vishal Singh
 
Page replacement algorithms
Piyush Rochwani
 
Virtual memory
Anuj Modi
 
Paging.ppt
infomerlin
 
Sliding window protocol
Shehara Abeythunga
 
Handheld operting system
Aj Maurya
 
INSTRUCTION LEVEL PARALLALISM
Kamran Ashraf
 
Process scheduling
Riya Choudhary
 
Memory management
Muhammad Fayyaz
 
Operating system services 9
myrajendra
 
Multi core-architecture
Piyush Mittal
 
Multiprocessor Systems
vampugani
 
Heap Management
Jenny Galino
 

Viewers also liked (7)

PPT
MULTITHREADING CONCEPT
RAVI MAURYA
 
PDF
Multithreaded processors ppt
Siddhartha Anand
 
PPTX
FIne Grain Multithreading
Dharmesh Tank
 
PPT
Ch5: Threads (Operating System)
Ahmar Hashmi
 
PPT
Parallel computing
Vinay Gupta
 
PPT
Chapter 2 - Operating System Structures
Wayne Jones Jnr
 
PPT
Flynns classification
Yasir Khan
 
MULTITHREADING CONCEPT
RAVI MAURYA
 
Multithreaded processors ppt
Siddhartha Anand
 
FIne Grain Multithreading
Dharmesh Tank
 
Ch5: Threads (Operating System)
Ahmar Hashmi
 
Parallel computing
Vinay Gupta
 
Chapter 2 - Operating System Structures
Wayne Jones Jnr
 
Flynns classification
Yasir Khan
 
Ad

Similar to Multithreading models.ppt (20)

PPT
Multithreading models
anoopkrishna2
 
PPT
15 threads
myrajendra
 
PDF
threads (1).pdfmjlkjfwjgliwiufuaiusyroayr
abhinandpk2405
 
PDF
Multithreaded Programming in oprating system
YOGENDRAMS
 
PPT
Treads
nayanashetty7
 
PPTX
Networking threads
Nilesh Pawar
 
PPT
chapter4-processes nd processors in DS.ppt
aakarshsiwani1
 
PPTX
Topic 4- processes.pptx
DanishMahmood23
 
PDF
Multithreaded Programming Part- II.pdf
Harika Pudugosula
 
PPTX
Operating system: threads(mulithreading,benefits of threads, types of thread)
sonuu__
 
PPTX
OS Module-2.pptx
bleh23
 
PPT
Ipc ppt
Ruchi Sharma
 
PPTX
Thread
Sajid Hussain
 
PPTX
Thread
sajidhuseyin
 
PPTX
Threading.pptx
BalasundaramSr
 
PDF
CH04.pdf
ImranKhan880955
 
PPT
Operating Systems - "Chapter 4: Multithreaded Programming"
Ra'Fat Al-Msie'deen
 
PDF
4 threads
Dr. Loganathan R
 
PDF
Threads lecture slides for operating systems
amirtarek401
 
PPTX
W-9.pptx
alianwarr
 
Multithreading models
anoopkrishna2
 
15 threads
myrajendra
 
threads (1).pdfmjlkjfwjgliwiufuaiusyroayr
abhinandpk2405
 
Multithreaded Programming in oprating system
YOGENDRAMS
 
Networking threads
Nilesh Pawar
 
chapter4-processes nd processors in DS.ppt
aakarshsiwani1
 
Topic 4- processes.pptx
DanishMahmood23
 
Multithreaded Programming Part- II.pdf
Harika Pudugosula
 
Operating system: threads(mulithreading,benefits of threads, types of thread)
sonuu__
 
OS Module-2.pptx
bleh23
 
Ipc ppt
Ruchi Sharma
 
Thread
sajidhuseyin
 
Threading.pptx
BalasundaramSr
 
CH04.pdf
ImranKhan880955
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Ra'Fat Al-Msie'deen
 
4 threads
Dr. Loganathan R
 
Threads lecture slides for operating systems
amirtarek401
 
W-9.pptx
alianwarr
 
Ad

More from Luis Goldster (20)

PPTX
Ruby on rails evaluation
Luis Goldster
 
PPTX
Design patterns
Luis Goldster
 
PPT
Lisp and scheme i
Luis Goldster
 
PPT
Ado.net & data persistence frameworks
Luis Goldster
 
PPTX
Business analytics and data mining
Luis Goldster
 
PPTX
Big picture of data mining
Luis Goldster
 
PPTX
Data mining and knowledge discovery
Luis Goldster
 
PPTX
Cache recap
Luis Goldster
 
PPTX
Directory based cache coherence
Luis Goldster
 
PPTX
Hardware managed cache
Luis Goldster
 
PPTX
How analysis services caching works
Luis Goldster
 
PPT
Abstract data types
Luis Goldster
 
PPTX
Optimizing shared caches in chip multiprocessors
Luis Goldster
 
PPTX
Api crash
Luis Goldster
 
PPTX
Object model
Luis Goldster
 
PPTX
Abstraction file
Luis Goldster
 
PPTX
Object oriented analysis
Luis Goldster
 
PPT
Abstract class
Luis Goldster
 
PPTX
Concurrency with java
Luis Goldster
 
PPTX
Data structures and algorithms
Luis Goldster
 
Ruby on rails evaluation
Luis Goldster
 
Design patterns
Luis Goldster
 
Lisp and scheme i
Luis Goldster
 
Ado.net & data persistence frameworks
Luis Goldster
 
Business analytics and data mining
Luis Goldster
 
Big picture of data mining
Luis Goldster
 
Data mining and knowledge discovery
Luis Goldster
 
Cache recap
Luis Goldster
 
Directory based cache coherence
Luis Goldster
 
Hardware managed cache
Luis Goldster
 
How analysis services caching works
Luis Goldster
 
Abstract data types
Luis Goldster
 
Optimizing shared caches in chip multiprocessors
Luis Goldster
 
Api crash
Luis Goldster
 
Object model
Luis Goldster
 
Abstraction file
Luis Goldster
 
Object oriented analysis
Luis Goldster
 
Abstract class
Luis Goldster
 
Concurrency with java
Luis Goldster
 
Data structures and algorithms
Luis Goldster
 

Recently uploaded (20)

PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Designing Production-Ready AI Agents
Kunal Rai
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 

Multithreading models.ppt

  • 2. Multithreading models • There are three dominant models for thread libraries, each with its own trade-offs – many threads on one LWP (many-to-one) – one thread per LWP (one-to-one) – many threads on many LWPs (many-to- many) • Similar models can apply on scheduling kernel threads to real CPUs
  • 3. Many-to-one • In this model, the library maps all threads to a single lightweight process • Advantages: – totally portable – easy to do with few systems dependencies • Disadvantages: – cannot take advantage of parallelism – may have to block for synchronous I/O – there is a clever technique for avoiding it • Mainly used in language systems, portable libraries
  • 4. One-to-one • In this model, the library maps each thread to a different lightweight process • Advantages: – can exploit parallelism, blocking system calls • Disadvantages: – thread creation involves LWP creation – each thread takes up kernel resources – limiting the number of total threads • Used in LinuxThreads and other systems where LWP creation is not too expensive
  • 5. Many-to-many • In this model, the library has two kinds of threads: bound and unbound – bound threads are mapped each to a single lightweight process – unbound threads may be mapped to the same LWP • Probably the best of both worlds • Used in the Solaris implementation of Pthreads (and several other Unix implementations)
  • 6. High-Level Program Structure Ideas • Boss/workers model • Pipeline model • Up-calls • Keeping shared information consistent using version stamps
  • 7. Thread Design Patterns Common ways of structuring programs using threads • Boss/workers model – boss gets assignments, dispatches tasks to workers – variants (thread pool, single thread per connection…) • Pipeline model – do some work, pass partial result to next thread • Up-calls – fast control flow transfer for layered systems • Version stamps – technique for keeping information consistent
  • 8. Boss/Workers Boss: Worker: forever { taskX(); get a request switch(request) case X: Fork (taskX) case Y: Fork (taskY) … } • Advantage: simplicity • Disadvantage: bound on number of workers, overheard of threads creation, contention if requests have interdependencies • Variants: fixed thread pool (aka workpile, workqueue), producer/consumer relationship, workers determine what needs to be performed…
  • 9. Pipeline • Each thread completes portion of a task, and passes results • like an assembly line or a processor pipeline • Advantages: trivial synchronization, simplicity • Disadvantages: limits degree of parallelism, throughput driven by slowest stage, handtuning needed
  • 10. Up-calls • Layered applications, e.g. network protocol stacks have top-down and bottom-up flows • Up-calls is a technique in which you structure layers so that they can expect calls from below • Thread pool of specialized threads in each layer – essentially an up-call pipeline per connection • Advantages: best when used with fast, synchronous control flow transfer mechanisms or program structuring tool • Disadvantages: programming becomes more complicated, synchronization required for top- down
  • 11. Version Stamps • (Not a programming structure idea but useful technique for any kind of distributed environment) • Maintain “version number” for shared data – keep local cached copy of data – check versions to determine if changed