Processes and Threads

Processes

A processes is the “heaviest” unit of  kernel scheduling. Processes own resources allocated by the operating system.
Resources include
a. memory
b. file handler
c. sockets
d. device handler
e. windows
Processes do not share address space or file resources except through explicit methods such as inheriting file handles or shared memory segments or mapping the same file in a shared way.
 
Threads
A thread of execution is the smallest unit of processing that can be scheduled by an operating system. In most cases a thread is contained inside a process.Multiple threads can exist within the same process and share resources such as memory while different processes do not share these resources.
 
On a single processor, multi-threading generally occurs by time division multiplexing, the processor switches between different threads. This context switching generally happens frequently enough that user perceives the threads or tasks are running at the same time.
On multiple processor, the threads or tasks will actually run at the same time, within each processor or core running a particular thread or tasks.
 
 S.No.  Processes  Threads
 1.  Processes are typically independent  Thread exist as subsets of a process.
 2.  Processes carry more state information than threads  Multiple threads within a process share process states as well as memory and other resources.
 3. Processes have separate address space  Threads share their address space
 4.  Processes interact only through system provided inter process communication.  
 5.  Context switching between processes are slow.  Context switching between threads in the same process is typically faster.
Rate this post

Leave a Reply