What is a process? in OS
Process in Operating System
In Operating system we define any process as a program in execution or instance of a program of the system, program is a static term however process means a running or active entity.
On batch systems, it is called as a “job” while on time sharing systems, it is called as a “task”.
A user who writes code for printing hello world. Before execution it is called program and after execution once it is in its binary form and is running and executed by system it gets broken down into multiple processes interacting with computing power and OS.
States of Processes
A process can be in the following states –
Apart from this a process in modern system can also be stated in the following two states –
- Suspended Ready
- Suspended Block
We will discuss these in detail below
Real life Scenario –
Let us consider we write a program to play a sound, when we execute this program this program creates a process for operating system. The operating system now queues up the command to implement and music is played. Simple !!!
Well, its not that simple even for a process to run in a modern OS there are many other stages in the life-cycle of a process, let’s discuss those in details.
Process Life Cycle
Process life cycle consists of the following stages –
- New – Whenever, a fresh process is created it gets available in the new state, it can collect relevant resources like data, I/O access etc in the mean time
- Ready – It gets assigned to ready stage where it waits to be assigned to a processor. This is a sort of a queue for all processes which are waiting for processor, such queue is called the Ready Queue.
- Running – The process is being executed by processor it gets into running stage.
- Waiting – Sometimes, cases happen when a process has to accept an additional input from user or maybe a higher priority process needs processor, in such cases the process goes to wait stage or waiting queue where all the processes are waiting for processor and complete their execution.
- Terminated – When process has completed executing its all instructions or when it’s ended by the user directly it goes to terminated stage.
Apart from this new age system also classify –
- Suspended Ready – If ready queue is full and has no space for new process then entry level process is in suspended Ready State
- Suspended Block – If the waiting queue is full
Every process has a process memory, which is generally divided into 4, this is done to make the most efficient functioning as possible –
- Stack – This houses all the temporary data and local variables like function parameters and addresses.
- Heap – When the process is in its run time, for dynamic memory allocation, for operations such as new(), delete(), malloc(), etc heap is used for fastest access at the run time.
- Text – Contains value of Program Counter and the contents of the processor’s registers which just the most low level instructions of the compiled program
- Data – Has static and global variables.
Process Control Block or PCB
To identify all active and blocked processes in the system the OS maintains a database of these. Read more about Process Control block here.
- Process (Intro)
- Process Life Cycle
- Process Control Block PCB
- Process Scheduling
- Context Switching
- CPU Scheduling
- FCFS Scheduling
- Shortest Job First (or SJF) scheduling – non-preemptive
- Shortest Job First (or SJF) scheduling – preemptive (SRTF)
- Round Robin scheduling
- Priority Scheduling
- Convoy Effect
- Difference between Scheduler and Dispatcher
- Preemptive scheduling vs Non Preemptive scheduling
- Preemptive scheduling
- Non preemptive scheduling