Threads

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Threads

 Threads are also known as Lightweight processes. Threads are a popular way to
improve the performance of an application through parallelism. Threads are
mainly used to represent a software approach in order to improve the
performance of an operating system just by reducing the overhead thread that
is mainly equivalent to a classical process.
 As each thread has its own independent resource for process execution; thus
Multiple processes can be executed parallelly by increasing the number of
threads.
Threads
Types of Thread

 There are two types of threads:

 User Threads

 Kernel Threads

 User threads are above the kernel and without kernel support. These are the threads that
application programmers use in their programs.

 Kernel threads are supported within the kernel of the OS itself. All modern OSs support kernel-
level threads, allowing the kernel to perform multiple simultaneous tasks and/or to service
multiple kernel system calls simultaneously.
Types of Thread
Multithreading Models

 The user threads must be mapped to kernel threads, by one of the following
strategies:

 Many to One Model

 One to One Model

 Many to Many Model


Many to One Model
 In the many to one model, many user-level threads are all mapped onto a single kernel
thread.
 Thread management is handled by the thread library in user space, which is efficient in
nature.
 In this case, if user-level thread libraries are implemented in the operating system in
some way that the system does not support them, then the Kernel threads use this
many-to-one relationship model.
One to One Model
 The one to one model creates a separate kernel thread to handle each and every user
thread.
 Most implementations of this model place a limit on how many threads can be
created.
 Linux and Windows from 95 to XP implement the one-to-one model for threads.
 This model provides more concurrency than that of many to one Model.
Many to Many Model
 The many to many model multiplexes any number of user threads onto an equal or
smaller number of kernel threads, combining the best features of the one-to-one and
many-to-one models.
 Users can create any number of threads.
 Blocking the kernel system calls does not block the entire process.
 Processes can be split across multiple processors.

You might also like