Different types of thread

Lists of Descriptive Questions Answers and Short Study Notes On Operating System – Different types of thread

  • (1) Different types of thread ,its advantages and disadvantages.

 

Question-1 Different types of thread ,its advantages and disadvantages

Types of thread

  1. User Level Threads
  2. Kernel Level Threads

 

1.User Level Threads

  • User level threads are implemented in user level libraries, rather than via systems calls.
  • So thread switching does not need to call operating system and to cause interrupt to the kernel.
  • The kernel knows nothing about user level threads and manages them as if they were single threaded processes.
  • When threads are managed in user space, each process needs its own private thread table to keep track of the threads in that process.
  • This table keeps track only of the per-thread properties, such as each thread’s program counter, stack pointer, registers, state, and so forth.
  • The thread table is managed by the run-time system.

 

Advantages

  • It can be implemented on an Operating System that does not support threads.
  • A user level thread does not require modification to operating systems.
  • Simple Representation: Each thread is represented simply by a PC, registers, stack and a small control block, all stored in the user process address space.
  • Simple Management: This simply means that creating a thread, switching between threads and synchronization between threads can all be done without intervention of the kernel.
  • Fast and Efficient: Thread switching is not much more expensive than a procedure call.
  • User-level threads also have other advantages. They allow each process to have its own customized scheduling algorithm.

 

 Disadvantages

  • There is a lack of coordination between threads and operating system kernel. Therefore, process as a whole gets one time slice irrespective of whether process has one thread or 1000 threads within. It is up to each thread to give up control to other threads.
  • Another problem with user-level thread packages is that if a thread starts running, no other thread in that process will ever run unless the first thread voluntarily gives up the CPU.
  • A user level thread requires non-blocking systems call i.e., a multithreaded kernel. Otherwise, entire process will be blocked in the kernel, even if a single thread is blocked but other runnable threads are present. For example, if one thread causes a page fault, the whole process will be blocked.

 

2.Kernel Level Threads

  • In this method, the kernel knows about threads and manages the threads.
  • No runtime system is needed in this case.
  • Instead of thread table in each process, the kernel has a thread table that keeps track of all threads in the system. In addition, the kernel also maintains the traditional process table to keep track of processes. Operating Systems kernel provides system call to create and manage threads.

 

Advantages

  • Because kernel has full knowledge of all threads, scheduler may decide to give more time to a process having large number of threads than process having small number of threads.
  • Kernel threads do not require any new, non-blocking system calls. Blocking of one thread in a process will not affect the other threads in the same process as Kernel knows about multiple threads present so it will schedule other runnable thread.

 

Disadvantages

  • The kernel level threads are slow and inefficient. As thread are managed by system calls, at considerably greater cost.
  • Since kernel must manage and schedule threads as well as processes. It requires a full thread control block (TCB) for each thread to maintain information about threads. As a result there is significant overhead and increased in kernel complexity.

threads types