Process vs. thread

The difference between process and thread is that process is an execution of program whereas thread is an execution of program driven by the environment of a process.

Advertisement - Continue Reading Below
Process vs. thread

There are many terms in computer science that very important and you can’t get along if you don’t learn about these terms. Process and thread are one of the most important concept in computer science. Process is an execution of program whereas thread is an execution of program driven by the environment of a process. Any process and thread are totally different from each other. Every process is different from each other threads share memory and resources. When the program is made, set of instructions are performed to execute these instruction this is basically known as process. The operating system of a computer creates, schedules and also the terminates the processes. There are parent processes and child processes.  Process control block is responsible for controlling the process operations in computer. Process control block contains all the crucial information of the process. Every process has its own process id, priority state, PWS and contents of CPU. The thread is program execution that uses the process resources for task.  Process contain thread, process is a container and thread is a content of that container. Kernel of operating system allocates a stack and a thread control block to each thread. The thread control block is responsible of switching between the threads of the same process. There are types of threads such as kernel-lever threads, user-level threads, hybrid threads. There are further three states of thread such as running, ready and blocked.

Advertisement - Continue Reading Below

Process control block is a kernel based data structure that uses there important features such as scheduling, dispatching, context save. Scheduling is the method of selecting the sequence of the process. Dispatching is process that sets up an environment for the process to be executed. Context save is a process that save the information.  When you create the process, there is a system call for each process. A process is an isolated execution entity and it share data and information.  Every process uses IPC that is inter-process communication which increases the number of system calls.  There are priority property in threads in this way there are multiple threads are active. One system can create one thread. Thread can share data and information whereas process cannot.

Comparison Chart

BasisProcessThread
MeaningThe process is execution of the program

The thread is execution of a program driven by the environment of a process.

Advertisement - Continue Reading Below

 

MemoryThe process does not share any memory.Thread share memory and resources.
Efficiency The process is less efficient than threadThe thread is more efficient than the process
Time The process takes more timeThe thread takes less time

What is Process?

When the program is made, set of instructions are performed to execute these instruction this is basically known as process. The operating system of a computer creates, schedules and also the terminates the processes. There are parent processes and child processes.  Process control block is responsible for controlling the process operations in computer. Process control block contains all the crucial information of the process. Every process has its own process id, priority state, PWS and contents of CPU. Process control block is a kernel based data structure that uses there important features such as scheduling, dispatching, context save. Scheduling is the method of selecting the sequence of the process. Dispatching is process that sets up an environment for the process to be executed. Context save is a process that save the information.  When you create the process, there is a system call for each process. A process is an isolated execution entity and it share data and information.  Every process uses IPC that is inter-process communication which increases the number of system calls. The system that have more than one processor is known as a multiprocessing system. More than two processors are added to increase the power of computer. CPU have set of registers the process is stored in these registers. For example if the process of addition of two numbers is made the integers will be saved in registers and the addition of number is also stored in a register. If there will be more than one process, there will be more registers than if one processor will do work and other will be free in this way power of the computer is increased. There are types of processors such as symmetric multiprocessing and asymmetric multiprocessing. If we talk about symmetric multiprocessing, in symmetric multiprocessing the processor is free to run and can run any process whereas in the case of multithreading there is a master-salve relationship. In multiprocessing, there is an integrated memory controller that job of the integrated memory controller is to add more memory.

What is Thread?

The thread is program execution that uses the process resources for task.  Process contain thread, process is a container and thread is a content of that container. Kernel of operating system allocates a stack and a thread control block to each thread. The thread control block is responsible of switching between the threads of the same process. There are types of threads such as kernel-lever threads, user-level threads, hybrid threads. There are further three states of thread such as running, ready and blocked.  There are priority property in threads in this way there are multiple threads are active. One system can create one thread. Thread can share data and information whereas process cannot. In multithreading, multiple threads are created.  A thread in multithreading is a process means a code segment of a process. A thread have its own thread ID, program counter, registers and stack. If we create separate processes for each service, then each processor share code, data and system resources. If we do not create threads the system can get exhausted. Creating threads can make processor easy for working. The responsiveness is increased in multithreading and this is the best advantage of using multithreading. The big advantage of multithreading is resource sharing and in resource sharing the several threads of a process share same code.

Key Differences

  1. Process is an execution of program whereas Thread is an execution of program driven by the environment of a process.
  2. The process does not share any memory whereas Thread share memory and resources.
  3. The process is less efficient than thread whereas Thread is more efficient than process.
  4. The process takes more time whereas Thread takes less time
Advertisement - Continue Reading Below

Conclusion

In this article above we see the clear difference between process and thread with code example.

Explanatory Video

Leave a Comment