Threads

Thread is an execution unit which consists of its own program counter, a stack, and a set of registers. Threads are also known as Lightweight processes. Threads are popular way to improve application through parallelism. The CPU switches rapidly back and forth among the threads giving illusion that the threads are running in parallel.

As each thread has its own independent resource for process execution, multpile processes can be executed parallely by increasing number of threads.

Single Threaded and Multithreaded Process

There are two types of threads :

  • User Threads
  • Kernel Threads

User threads, are above the kernel and without kernel support. These are the threads that application programmers use in their programs.

Kernel threads are supported within the kernel of the OS itself. All modern OSs support kernel level threads, allowing the kernel to perform multiple simultaneous tasks and/or to service multiple kernel system calls simultaneously.

Contributor's Info

Created:
0Comment
Thread
  1. A thread is a light-weight process. A process can have one or more threads is known as multi- threading.
  2. Threads of a same process share some items, i.e, address space, global variables, opened fines, signal handlers, child process, pending alarms, memory and I/O etc.

Threads of a same process never share its CPU register and Stack.

 

Processes have its own address space but threads share address space of same process that created it. So, threads are easier to create than processes. Threads minimizes context switching time than processes. Threads are economical.

 

Contributor's Info

Created:
0Comment