What is a process? in OS
Process in Operating System
The world of operating systems is a complex and fascinating one. It involves the coordination and management of various system resources to ensure efficient and reliable execution of tasks. One fundamental concept in operating systems is a process.
In this article, we will explore the concept of a process, its states, management, and significance in the realm of operating systems.
Understanding the Process States
A process can exist in different states during its lifetime. The common process states include:
- New: This is the initial state when a process is being created.
- Ready: The process is loaded into main memory and waiting to be assigned to a processor.
- Running: The process is being executed by a processor.
- Blocked: The process is unable to execute further until a certain event occurs, such as waiting for user input or completion of I/O operations.
- Terminated: The process has completed its execution or has been forcefully terminated.
Process Scheduling
Process scheduling is a vital aspect of operating system design. It determines the order in which processes are executed by the processor.
Different scheduling algorithms, such as First-Come, First-Served (FCFS), Shortest Job Next (SJN), Round Robin (RR), and Priority Scheduling, are used to allocate CPU time to processes efficiently. These algorithms aim to optimize resource utilization and minimize process waiting times.
Process Creation
Processes are created in various ways, such as when a user initiates a program or when the operating system launches system processes during startup. The process creation involves allocating necessary resources, setting up the execution environment, and initializing the process control block. Once created, the process enters the new state and awaits execution.
Process Termination
Process termination occurs when a process finishes executing its task or when it is explicitly terminated by the operating system. Upon termination, the operating system releases the allocated resources, updates the process’s state to “terminated,” and removes its PCB from the system.
Interprocess Communication
In modern operating systems, processes often need to communicate and share information with each other. Interprocess communication (IPC) mechanisms facilitate this exchange of data between processes. Common IPC methods include shared memory, message passing, pipes, and sockets. These mechanisms enable efficient coordination and collaboration among different processes.
States of Processes
A process can be in the following states –
- New
- Ready
- Run
- Wait
- Running
- Terminated
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
Process Elements
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 (PCB)
- The Process Control Block (PCB) is a data structure used by the operating system to manage and keep track of processes.
- It contains important information about a process, including its current state, program counter, CPU registers, memory allocation details, and more.
- The PCB allows the operating system to effectively manage and switch between processes, ensuring fair allocation of resources.
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment