Types of threads in Operating System

There are two types of threads in a system

  1. Kernel Level Threads
  2. User Level Threads

  1.  User Level Thread: This is user-application created task/thread that is implemented by libraries such as posix, java thread etc. These library internally uses the interface published by OS to create manage threads.
  2. Kernel Level Thread: The actual entity that is being scheduled by CPU to perform a given task. It is closely associated with Hardware. Operating system has total control over it. It is the OS that create, manages and destroy kernel level thread as per the requirement received on interface published by OS for user [i.e. user application]

Note: A User Level thread must be associated with Kernel Level Thread.

There are 3 types of mapping/association exist between User Level Thread and Kernel Level Thread

User Level Thread and Kernel Level Thread Mapping and Working
User Level Thread and Kernel Level Thread Mapping and Working.


M:1

Multiple User Level Threads are associated with single Kernel Level Thread. This is generally happen single threaded system. Green thread a Solaris 2 library uses it.

Advantages

  • Simple to implement

Dis-advantages

  • If one thread makes blocking system-call then all other threads are blocked, complete system on halt until blocking system-call is completed.

1:1

A User level thread is directly associated with a kernel level thread. In addition, remain associated until task is completed. Windows NT, Windows 2000 implements this one-to-one model.

Advantages

  • Better than one-to-many model

Dis-advantages

  • There are finite number of kernel threads available on a given system so user shall not be able to create more user-level thread than that finite number.

M:N

M number of User Level threads are associated with a pool of Kernel Level Threads. UNIX uses this kind of association.

Advantages

  • Better than one-to-one
  • There is theoretically no restrictions on number of user-level threads created.


Your Comments /Suggestions & Questions are always welcome. 
We would like to help you with best of our knowledge. 
So feel free to put Questions.

No comments: