Explain user thread and kernel threads | Operating System Question & Answer

User-Level Threads:  
 A user-level thread is a thread within a process which the OS does not know about. 
 In a user-level thread approach the cost of a context switch between threads less since the operating system itself does not need to be involved–no extra system calls are required. 
 A user-level thread is represented by a program counter; registers, stack, and small thread control block (TCB). 
 Programmers typically use a thread library to simplify management of threads within a process.  
 Creating a new thread, switching between threads, and synchronizing threads are done via function calls into the library. This provides an interface for creating and stopping threads, as well as control over how they are scheduled. 

Kernel Threads: 
 In systems that use kernel-level threads, the operating system itself is aware of each individual thread. 
 Kernel threads are supported and managed directly by the operating system. 
 A context switch between kernel threads belonging to the same process requires only the registers, program counter, and stack to be changed; the overall memory management information does not
need to be switched since both of the threads share the same address space. Thus context switching between two kernel threads is slightly faster than switching between two processes. 
 Kernel threads can be expensive because system calls are required to switch between threads. Also, since the operating system is responsible for scheduling the threads, the application does not have
any control over how its threads are managed. 

Post a Comment

0 Comments