Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 4 Silberschatz Threads (Thread Libraries (Pthread (Refers to the…
Chapter 4
Silberschatz
Threads
Overview
Motivation
Most software applications that run on moderns computers are multithreaded.
Benefits
Responsiveness
Resource sharing
Economy
Scalability
Is a basic unit of CPU utilization; it comprises a thread ID, a program counter, a register set, and a stack.
Multicore Programming
Programming Challenges
The trend towards multicore systems continues to place pressure on system designers and application programmers to make better use of the multiple computing cores.
Identifying tasks
Balance
Data Splitting
Data Dependency
Testing and debugging
Types or Parallelism
Data Parallelism
Focuses on distributing subsets of the same data across multiple computing cores and performing the same operation on each cor
Task Parallelism
Distributes tasks across multiple computing cores. Each thread is performing a unique operation.
Multithreading Models
One to One Model
Maps each user thread to a kernel thread.
Many to Many Model
Multiplexes many user-level threads to smaller or equal number of kernel threads
Many to One Model
Maps many user-level threads to one kernel thread
Thread Libraries
Libraries
Provides the programmer with and API for creating and managing threads
Pthread
Refers to the POSIX standard defining an API for thread creation and synchronization.
Windows thread
Java Thread
Implicit Threading
One way to address the difficulties and better support the design of multithreaded applications is to transfer the creation and management of threading from application developers to compilers and run-time libraries.
6.Threading Issues
The fork() and exec() System calls
fork()
Some UNIX systems have two versions, one that duplicates all threads and another that duplicates the thread that invoked the fork()
exec()
If a thread invokes the exec(), the program specified in the parameter to exec() will replace the entire process.
Signal handling
All signals follow the same pattern
A signal is generated by the occurrence of a particular event
The signal is delivered to a process
Deliver the signal to the thread to which the signal applies.
Deliver the signal to every thread in the process
Delier the signal to certain threads in the process
Assign a specific thread to receive all signals for the process
The signal must be handled
A default signal handler
A user-defined signal handler
Thread cancellation
Deferred cancellation
The target thread periodically checks whether it should terminate, allowing it an opportunity to terminate itself in an orderly fashion.
Asynchronous cancellation
One thread immediately terminates the target thread
Thread-Local storage
In some circumstances, each thread might need its own copy of certain data.
Scheduler activations
We can use a lightweight process (LWP) that appears to be a virtual processor on which the application can schedule a user thread to run. Each LWP is attached to a kernel thread.
Daniela Porras Quiros
2015071255