We all are aware of the computer and the operating system. All the CPU activities that are going on are termed as a process in an operating system. Well, there are several definitions of the term ‘process’ in the operating system.
Like, some call the process a program or an instance of a program that is currently in execution. Some call it an entity that can be executed on the processor. Some call it a unit of activities that contains a sequence of instructions that are in execution.
Table of Contents
Concept of Process in Operating System
In the early batch systems, CPU activities are termed jobs. When it comes to a time-sharing system, the CPU activities are termed user programs or tasks. And a single-user system like Windows, where even the user is executing one program at a time, the CPU is involved in its own programmed activities like memory management. All these activities performed by the CPU are termed as a process.
In the operating system for all CPUs, activities are preferred by the term process. The process is not only the set of instructions, which is known as a text section it has many more to be concerned about.
Must Read: Threads in Operating System
Elements of Process
The two most important components of a process are program code and a set of data. The program code is a set of instructions, whereas the set of data is the collection of data that is associated with the code of the program. Now, consider that the processor starts executing the program code along with the data associated with it then, it is a process.
Well, when the process is in execution, it can be characterized by the elements discussed below:
- Identifier: Every process has a unique identification which helps the processor distinguish between the processes. Every process has a process Id which acts as an identifier for that process.
- State: A process can be in a ready state, waiting for a state, a new state, and a terminating state.
- Priority: There are several processes in the system. But each process must have a priority level, which helps the processor in deciding what process should be responded to first.
- Program Counter: As we have seen, a process has a program code that has a set of instructions. The program counter helps the processor identify which instruction is to be executed next.
- Memory Pointer: The memory pointer contains the pointer to the program code and to the data that is associated with the program.
- Context Data: While the process is executing, the processor stores the intermediate results in the registers, which is context data.
- I/O Status Information: A process may require the I/O devices for which it makes the I/O requests. It also has information about the files used by the process.
- Accounting Information: The accounting information has information about the time spent by the process on the processor.
All this information is organized inside a data structure, and it is termed the process control block.
Process Control Block
The operating system creates a process control block for each process. A process control block has all that information about the process, which would help the processor to interrupt any process which is currently executing and also resume the interrupted process. The diagram below shows the process control block.
The operating system creates as well as manages the process control block. It is all because of the process control block that an operating system has the ability to support multiprocessing.
Must Read: Process Scheduling
From the moment the process is ready for execution and till it gets executed it changes its state. Identification of the state of the process is possible by its current activity. At a time, a process can be in only one state. Below are the states of the process.
- New: A process is in a new state when it is just created.
- Ready: A process is in a ready state when it is prepared for execution.
- Running: A process is in the running state when the execution of instructions is under process.
- Waiting: When the operating system puts the process on hold for some time, it is in waiting for the state.
- Terminated: When the process has completed its execution, it gets terminated.
The current state of the process is updated by the operating system in the process control block.
So, this is all about Process in Operating System