Operating System Concepts – 8th Edition
Silberschatz, Galvin and Gagne ©2009
Chapter 4: Threads
Overview
Multithreading Models
Thread Libraries
Threading Issues
Operating System Examples
Windows XP Threads
Linux Threads
Operating System Concepts – 8th Edition
4.2
Silberschatz, Galvin and Gagne ©2009
Objectives
To introduce the notion of a thread — a fundamental unit of CPU utilization that forms the basis of multithreaded computer systems
To discuss the APIs for the Pthreads, Win32, and Java thread libraries
To examine issues related to multithreaded programming
Operating System Concepts – 8th Edition
4.3
Silberschatz, Galvin and Gagne ©2009
Motivation
Threads run within application
Multiple tasks with the application can be implemented by separate threads
Update display
Fetch data
Spell checking
Answer a network request
Process creation is heavy-weight while thread creation is light-weight
Can simplify code, increase efficiency
Kernels are generally multithreaded
Operating System Concepts – 8th Edition
4.4
Silberschatz, Galvin and Gagne ©2009
Single and Multithreaded Processes
Operating System Concepts – 8th Edition
4.5
Silberschatz, Galvin and Gagne ©2009
Benefits
Responsiveness
Resource Sharing
Economy
Scalability
Operating System Concepts – 8th Edition
4.6
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.7
Silberschatz, Galvin and Gagne ©2009
Multithreaded Server Architecture
Operating System Concepts – 8th Edition
4.8
Silberschatz,