To better understand this question, let's first take a look at what is a program.A program is an executable file containing a set of instructions and passively stored on disk.
One program can have multiple processes.For example, the chrome browser creates a different process for every single tab.
A Process means a program is in execution.When a program is loaded into the memory and becomes active, the program becomes a process.The process requires some essential resources such as registers,program counter,and stack.
A Thread is the smallest unit of execution within a process.
Main differences between process and thread:
- processes are usually independent,while threads exist as subsets of a process.
- Each process has its own memory space.Threads that belong to the same process share the same memory. -A process is a heavyweight operation. It takes more time to create and terminate. -Context switching is more expensive between processes. -Inter-thread communication is faster for threads.
Top comments (0)