Chapter 4: Multithreaded Programming Week 6 08.03.2011
Chapter 4: Multithreaded Programming Week 6 08.03.2011
Programming
Week 6
08.03.2011
Operating System Concepts – 8th Edition, Silberschatz, Galvin and Gagne ©2009
Outline For Today
Process and threads
Single and Multithreads
Benefits and issue regarding Multithreading
Multi threading on Single and multicore system
Multithread Model
Operating System Concepts – 8th Edition 4.2 Silberschatz, Galvin and Gagne ©2009
Process and Threads
Processes are typically independent, while threads exist as subsets of a
Process
Processes carry considerable STATE information, whereas multiple
threads within a process share state as well as MEMORY and other
RESURCES
Processes have separate ADDRESS SPACES, whereas threads share
their address space
CONTEXT SWITCHING between threads in the same process is typically
faster than context switching between processes.
Operating System Concepts – 8th Edition 4.3 Silberschatz, Galvin and Gagne ©2009
Single and Multithreaded Processes
Operating System Concepts – 8th Edition 4.4 Silberschatz, Galvin and Gagne ©2009
Benefits
Responsiveness
Resource Sharing
Economy
Scalability
Operating System Concepts – 8th Edition 4.5 Silberschatz, Galvin and Gagne ©2009
Multicore Programming
Multicore systems putting pressure on programmers, challenges include
Dividing activities
Balance
Data splitting
Data dependency
Testing and debugging
Operating System Concepts – 8th Edition 4.6 Silberschatz, Galvin and Gagne ©2009
Multithreaded Server Architecture
Operating System Concepts – 8th Edition 4.7 Silberschatz, Galvin and Gagne ©2009
Execution on a Single-core and multicore System
Operating System Concepts – 8th Edition 4.8 Silberschatz, Galvin and Gagne ©2009
Threads
User threads
Thread management done by user-level threads library
Kernel threads
Supported by the Kernel
Operating System Concepts – 8th Edition 4.9 Silberschatz, Galvin and Gagne ©2009
Multithreading Models
Many-to-One
One-to-One
Many-to-Many
Operating System Concepts – 8th Edition 4.10 Silberschatz, Galvin and Gagne ©2009
Many-to-One
Many user-level threads mapped to single kernel thread
Examples:
Solaris Green Threads
GNU Portable Threads
Operating System Concepts – 8th Edition 4.11 Silberschatz, Galvin and Gagne ©2009
Many-to-One Model
Operating System Concepts – 8th Edition 4.12 Silberschatz, Galvin and Gagne ©2009
One-to-One
Each user-level thread maps to kernel thread
Examples
Windows NT/XP/2000
Linux
Solaris 9 and later
Operating System Concepts – 8th Edition 4.13 Silberschatz, Galvin and Gagne ©2009
One-to-one Model
Operating System Concepts – 8th Edition 4.14 Silberschatz, Galvin and Gagne ©2009
Many-to-Many Model
Operating System Concepts – 8th Edition 4.15 Silberschatz, Galvin and Gagne ©2009
Many-to-Many Model
Operating System Concepts – 8th Edition 4.16 Silberschatz, Galvin and Gagne ©2009
End of today Lecture
Operating System Concepts – 8th Edition 4.17 Silberschatz, Galvin and Gagne ©2009