Process and Thread in Operating System

 What is process? - A program in exaction is called process.

Technically, Process is not just program (code) in execution, but it consists of text section where code is placed, a program counter that represents current activity, a set of registers, stack where temporary data (such as method, arguments, local variable are placed and a data section that stored global variable/data.

Each process has various states of execution such as New, Running, Waiting, Ready and Terminated etc. these name are not standard but used to represent process state in Operating System.

Each process in Operating System shall have a process control block (PCB). It stores various information about the process such as process state, program counter, CPU-Registration Information, Scheduling information, Memory Management information and I/O state etc.

What is a single-threaded process? – A process with single flow of control is called as single threaded process.

Single threaded process shall perform one and only one task at a time. If our web-browser would have been single-threaded then we would be able to open one tab. Moreover, if our MS-Word would have been a single-threaded process then we would not able to do typing and spellcheck simultaneously.

What is thread? – Thread is a light-weight process that have a unique Thread-Id, a program counter, set of registers and dedicated stack. While code-section, data-section and other operating system resource such as files, signals etc. are shared among thread.

Why thread is called light-weighted? - Because for Operating system it is much lighter to create, maintain and destroy a thread as compare to traditional process.

Single Threaded vs Multi Threaded
Single Threaded vs Multi-Threaded

                                                                                                                     Types of threads  :: NEXT

Your Comments /Suggestions & Questions are always welcome.
We would like to help you with best of our knowledge. 
So feel free to put Questions.

No comments:

Post a Comment