Register Login

Difference between Process and Thread with Comparison Chart

Updated Feb 19, 2019

A process can be referred to as an active program. It is a program that is in the process of execution. It includes the process stack, registers, program code, program counter and so forth. On the other hand, a relatively lightweight process, a thread is capable of being managed independently with the help of a scheduler. It shares information pertaining to data segment, files, code segment, etc. with other threads while showcasing its own counter, registers, stack, etc. Though the terms process and thread are used interchangeably, they are quite different in meaning and attributes. This article will help you understand why a thread and process are not the same.

Process vs Thread

Basis of Differentiation

Process

Thread

System calls

A process involves system calls.

There are no system calls involved in a thread.

Context switching

There is requirement of context switching in a process.

No context switching is possible in a thread.

Data and code sharing

Different processes have varied copies of data and code.

The sharing of the same copy of data and code becomes possible among varying threads.

Treatment by operating systems

Operating system work on different processes differently.

The user level threads are treated as a singular task by operating systems.

Blockage

In case any process gets blocked, the remaining processes carry on with their work.

In case a user level thread experiences a blockage, the remaining threads also get restricted as the threads are considered to be a singular task by an operating system. Such blockage is capable of being avoided by kernel level threads.

Interdependence

A process is independent in nature.

A thread exists as a subset of a given process and is dependent on it.

Memory space

A process runs in a different memory space than the thread.

A thread runs in the same memory space as the process it belongs to.

Shareability

Processes possess their individual program counter (PC), stack space and register set.

A thread shares the code section, address space, data section, etc. with the other threads.

Time consumed

The communication that takes place between the processes needs some time.

The communication taking place between threads requires lesser time than processes.

Memory space allocation

Processes fail to share their memory space with other processes.

Threads can share their memory space with other threads belonging to the same process.

Overheads

A process contains overheads.

Threads bear no overheads.

What is Process?

Every process provides resources that are necessary for executing specific programs. A process showcases a virtual address space and contains open handles linked to system objects, security context, environment variables, executable codes, unique process identifiers, priority classes, working set sizes (minimum and maximum), a minimum of one execution thread, etc. Every process is initiated with the help of a singular thread, which is referred to as the primary thread. It is possible to create more threads from any given thread in a specific process.

  • The executing instance of any specific program is termed as a process.
  • In some operating systems, the word task is assigned to the program that is under execution.
  • A process is saved in the random access memory or primary memory of the system.
  • It is an active entity that disappears in case the machine is rebooted.
  • A singular program may have several processes. Multiple processes are capable of being executed in parallel on multiprocessor systems.
  • Even though true parallelism cannot be achieved on uni-processor systems, it is possible to apply process scheduling algorithms, wherein the processes can be scheduled to execute in a manner that depicts an illusion of concurrency.

What is Thread?

A thread refers to an entity that lies within a process. It can be scheduled for the purpose of execution. The threads present in any given process are capable of sharing its system resources and virtual address space. Exception handlers are maintained by each thread along with a scheduling priority, unique thread identifier, thread local storage, exception handlers, as well as a set of structures that’s used for saving the thread context till the same is scheduled.

The context of the thread incorporates the thread's machine registers, thread environment block, kernel stack, as well as a user stack that’s present in the address space belonging to the thread's process. In certain cases, threads depict their individual security context that is capable of impersonating clients.

  • A thread is derived from a process and is its subset.
  • As it is quite the same as a real process, a thread executes in the context of a process, shares all resources as assigned to a process by the kernel, etc. A thread is but a ‘lightweight process.’
  • In general, a process contains a singular thread of control wherein a single set of machine instructions can be executed at a time.
  • A process is capable of containing multiple executions threads that are equipped to execute instructions concurrently.
  • Multiple control threads are designed to exploit the parallelism that is possible on multiple processor systems.
  • Thread scheduling algorithms can be applied on uni-processor systems, wherein the process can be scheduled for running singular threads at any given point of time.
  • The threads that run within a process possess the same address space, stack, file descriptors, as well as other process linked attributes.
  • As process threads use the same memory, the synchronization of access to shared data contained in the process becomes most significant.

Key difference between Thread and Process

  • Threads are useful for small-sized tasks, the processes are put into use for the more ‘heavyweight’ tasks. – primarily for the execution of different applications.
  • Additionally, the threads belonging to any given process can be found in the same address space; conversely, different processes cannot share the same address space.

Conclusion

This close look at the difference between process and thread will help you understand their usage in better ways. In case you have any more differences to share, please write back to us in the comments section given below. We will wait to hear from you.


×