Professional Documents
Culture Documents
Lecture 7
Suad Alaofi 1
Outlines
Threads
Threads Uses
Threads Benefits
Multicore Processor
Multithreading Models
2
Threads
4
Threads Uses
1. Responsiveness:
Multithreading an interactive application may allow a program to
continue running even if part of it is blocked or is performing a
lengthy operation, thereby increasing responsiveness to the user.
For instance, a multithreaded Web browser can allow user
interaction in one thread while an image is being loaded in
another thread.
2. Resource sharing:
Threads share the memory and the resources of the process to
which they belong by default.
6
Cont.
3. Economy:
Allocating memory and resources for process creation is costly.
Because threads share the resources of the process to which they
belong, it is more economical to create and context-switch
threads.
4. Scalability:
Multithreading on amulti- CPU machine increases parallelism.
A single-threaded process can only run on one processor,
regardless how many are available.
7
Multicore Processor
9
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.
kernel threads are supported and managed directly by the operating
system.
A relationship must exist between user threads and kernel threads.
There are three common models of relationships:
1. Many-to-One Model
2. One-to-One Model
3. Many-to-Many Model 10
Many-to-One Model
11
One-to-One Model
13