Monday, May 06, 2013

USER LEVEL THREAD VS KERNEL LEVEL THREAD:


USER LEVEL THREAD:

[1]User threads are supported above the kernel and are implemented by thread library at the user level.
[2] A library provides support for thread creation, scheduling and management with no support from kernel.
[3] Kernel is unaware of user level thread.  Creation and scheduling are done without need for kernel interaction. So user level threads are faster and easier to create and manage than kernel level thread.
[4]If the kernel is single threaded then any user level thread performing a blocking system call will cause the entire process to block even if there are other threads available to run within application.
[5]User level thread library includes POSIX P threads, MACH C threads, SOLARIS
[6] User level thread are created managed in user level memory.

KERNEL LEVEL THREAD:

[1] Kernel threads are supported directly from OS.
[2]Thread creation scheduling and management are done in kernel space (kernel memory) with the help of OS directory.
[3]It is slower to create and manage. However the kernel is managing the thread if a thread (user) performing a block system call, another thread of kernel can schedule another thread in the application for execution.
[4]Window’s NT, SOLARIS and digital UNIX are the operating system that supports kernel thread.

PROCESS VS THREADS


Some points of differences between process and thread are as follows:

[1]  Threads cannot live on its own, it must live within a process while process cam live on its own. Process has its own input, resources etc.

[2]   There can be more than one thread in a process but there it is not possible to have two process in a single thread.

[3]   The thread creation is inexpensive because OS  does not involve while the process creation is expensive .

[4]   Threads minimize the context switching while the process has expensive context switching.

[5]   If a thread in a process dies, another thread in a thread stack can run. but if a process dies, its resources are de-allocated and all its thread dies.

[6]  Process has separate address space where as thread share the address space.

[7]  Threads are easier to create because they don’t require separate address space where as process are complex to create because it requires separate address space.

[8]  Threads are considered light weight because they uses less resources then processes.