0% found this document useful (0 votes)
28 views

User & Kernel Threads

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

User & Kernel Threads

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

• User and Kernel Threads

• Practically, threads can be implemenuser ted at


two different levels namely, User Level (User
Threads) and Kernel Level (Kernel Threads)
• A library which provides the programmers with
an Application Programming Interface(API) for
thread creation and management is known as
Thread Library.
• A Thread Library Maps the User threads to Kernel
threads.
• User Threads
• The threads implemented at user level are known
as user threads. In user level threads, the thread
management is done by the application and the
kernel is not aware of existence of threads.
• User threads are supported above the kernel and
are implemented by a thread library at the user
level. The library provides support for thread
creation, scheduling, execution and management
with no support from the kernel. So user level
threads are fast to create and manage.
• Examples of user level threads are POSIX
Pthreads, Mach C-threads and Solaris threads.
• Kernel Threads
• The threads implemented at kernel level are known
as kernel threads. Kernel Threads are supported
directly by the operating system.
• The kernel performs thread creation, scheduling,
execution and management in kernel space.
• As thread management is done by operating system,
kernel threads are slower to create and manage than
user threads.
• If a thread performs blocking system call , the kernel
can schedule another thread in the application for
execution.
• Examples of kernel threads are Windows NT,
Windows 2000, Solaris 2, BeOs etc
• Difference between User Level & Kernel Level Thread

User level thread Kernel level thread


User thread are implemented by users. kernel threads are implemented by OS.
OS doesn’t recognize user level threads. Kernel threads are recognized by OS.

Implementation of Kernel thread is


Implementation of User threads is easy.
complicated.

Context switch time is less. Context switch time is more.

Context switch requires no hardware


Hardware support is needed.
support.

If one user level thread perform blocking If one kernel thread perform blocking
operation then entire process will be operation then another thread can continue

blocked. execution.

User level threads are designed as Kernel level threads are designed as
dependent threads. independent threads.

Example : Java thread, POSIX threads. Example : Window Solaris.


• Multithreading Models
• Many operating systems support kernel
thread and user thread in a combined way.
Example of such system is Solaris. Multi
threading model are of three types.
1.One to one model.
• 2.Many to one model.
• 3.Many to many model.
• One to One Model
In this model, one to one relationship between
kernel and user thread. In this model multiple
thread can run on multiple processor. Problem
with this model is that creating a user thread
requires the corresponding kernel thread.
• As each user thread is connected to different
kernel , if any user thread makes a blocking
system call, the other user threads won’t be
blocked.
• Many to One Model
• In this model, we have multiple user threads
mapped to one kernel thread. In this model
when a user thread makes a blocking system
call entire process blocks. As we have only one
kernel thread and only one user thread can
access kernel at a time, so multiple threads are
not able access multiprocessor at the same
time.
• The thread management is done on the user
level so it is more efficient.

• Many to Many Model
• In this model, multiple user threads multiplex
to same or lesser number of kernel level
threads.
• Number of kernel level threads are specific to
the machine.
• Advantage of this model is, if a user thread is
blocked we can schedule others user thread to
other kernel thread. Thus, System doesn’t
block if a particular thread is blocked.
• It is the best multi threading model.

You might also like