A program is a set of instructions which is used to perform some logical unit of task. The instructions inside the program are written in some high-level programming languages or any kind of scripting languages that the computer can’t understand. So, in order to make those instructions executable by processor, they are first converted to machine-level language with the help of compiler & Interpreter.
For example, Microsoft Word is an application program is ,used for typing and formatting text documents, Google Chrome is an application program used for Browsing the Internet etc…
A process is a program which is under execution. When a program needs to be executed it gets loaded in Main Memory(R.A.M) and then only it is considered as a Process. Inside a particular System ,there can be multiple Processes running simultaneously in a context switch manner, to achieve Multitasking. In general, Processes are Independent from one another, but strictly speaking, Process can be of 2 types:-
A) Independent Process & B) Co-Operative Process.
Let us discuss both of them in brief,
A) Independent Process:
The Processes which doesn’t effect neither get effected by others process which are in execution simultaneously within the same system are considered as Independent Process. In short Independent Processes doesn’t depend upon on other process for it’s execution.
B) Co-Operative Process:
The processes which effects or being effected by other by others process which are in execution simultaneously within the same system are considered as Co-Operative Process. In short, execution of these processes simultaneously may sometimes create unexpected output, & we may get Data-Inconsistency problem, if not managed & synchronized properly. This is due to the fact that these processes share the same shared Resource or some sort of shared data that they try to manipulate & perform operations on them at the same time.
Every Process, can remain in one of of the following states at a time.
1) Start : This is the state where the process is first initially created.
2) Ready : In this state, the Process waits for it’s execution until the Operating System allocates Processor.
3) Running: In this state, the process starts executing it’s instructions by the processor.
4) Waiting :In this state, the Process waits for a Resource ,or some Input/output operations to happen.
5) Terminated : Once the Process has completed it’s complete execution it moves into terminated state. In this state the process waits to be removed from main-memory.
Every Process has a dedicated Process Control Block(P.C.B) which is maintained by Operating system, to keep track of point of execution of each Processes running simultaneously. PCB has the following informations about the Process:
1) Process State, 2)Process Privileges,3) Process Id, 4) Pointer,5)Program Counter,6) CPU Registers, 7) Accounting Information,8) IO status Informations, 9) Memory Management information & 10) CPU Scheduling information.
A Thread is a unit of execution within a specific Process. In other words, a Thread is considered as light-weighted Process. Inside a particular Process there can be multiple Threads running simultaneously through Context Switching, this concept is known as Multithreading, & the Process is said to be a Multi-Threaded Process. However, a process can also have Single Thread associated with it, which is again called as Single-Threaded Process.
In a Multithreaded Process, each thread performs separate Independent tasks and each task is allocated to a particular Thread, so that each thread can execute their tasks simultaneously, as a result the whole task can be executed within a less amount of time, which in turn, will increase performance of the application.