2. Threads
• Thread is often referred to as a light weight
process. The process can be split down into
so many threads. For example, in a browser,
many tabs can be viewed as threads. It is a
basic unit of CPU utilization; it comprises a
thread ID, a program counter, a register set,
and a stack.
• In busy WWW server: The server creates a
separate thread that would listen for clients
requests, when a request was made, creates
a thread to service the request.
os5 2
5. Benefits
• Responsiveness: Allow a program to continue running
even if part of it is blocked or is performing a lengthy
operation.
• Resource sharing: several different threads of activity
all within the same address space.
• Economy: Allocating memory and resources for
process creation is costly.
• Utilization of multiprocessor architecture: Several
thread may be running in parallel on different
processors.
6. Types Of Threads
USER THREAD KERNEL THREAD
User Level Threads are simple and quick to create
and Can run on any operating system. Thread
management done by user-level threads library.
Kernel Thread is a thread that only runs
in kernel mode and has no user address space and
Kernel threads are supported directly by operating
system
7.
8.
9. Multithreading Models
Multi-Thread vs. Multi-process
Multiple process
Each is independent and has it own program counter,
stack register, and address space. This is useful for
unrelated jobs.
Multiple processes can perform the same task as well. E.g.,
provide data to remote machines in a network file system).
Each executes the same code but has it own memory and
file resources.
A multiple-thread process
It is more efficient to have one process containing multiple
threads serve the same task.
Most Systems Support for both user and kernel threads
11. Many-to-One
• Many user-level threads mapped to single
kernel thread.
• Used on systems that do not support kernel
threads.
Thread management is done in user space, so it is
efficient.
The entire process will block if a thread makes a
blocking system call.
Only one thread can access the kernel at a time,
multiple threads are unable to run in parallel on
multiprocessors.
15. Many-to-Many
• Multiplexes many user-level threads to a
smaller or equal number of kernel threads
• Allows the developer to create as many user
threads as wished.
The corresponding kernel threads can run in parallel on
a multiprocessor.
When a thread performs a blocking call, the kernel can
schedule another thread for execution.
• Solaris 2, IRIX, Digital UNIX.
• Windows NT/2000 with the Thread Fiber
package