In the previous section we have discussed the properties shown by an operating system ,their major features and their working with respect to operating system and how their work is dependent on the OS.Now, let us discuss about process in operating system.
Process in operating system
Basically, execution of a program is a process. A sequential pattern is a must use for the execution of all the tasks.
We term the implementation of a basic unit of work in the system as a process.
In order to understand the concept of a process in a more simpler and discrete language, take a look at the following points:
- A computer program is in a text file.
- It turns itself into a process after executing.
- All tasks mentioned in the program are then executed by this process.
Therefore, we say that any computer program when executed, runs as a process, and, executes some tasks.
Program and Memory:
A program takes the shape of a process when the operating system loads it into the memory. Now the process in operating system splits into four main parts which are:
What is stack?
Temporary data is stored in the process stack which includes:
- Method function variables.
- Return address
- Local variables
What is heap?
It is the Dynamic allocation of memory to a process.
Program counter has a value when program is in execution. Text includes the current activity represented by the value of program counter and contents of processor’s registers.
It is the area which contains the global and static variables in it. Following figure explains the memory division of program
In simple words we can say that a program is a piece of code. It can be of single line or multiple lines (which can be in millions). Usually a programmer writes a code in programming language.
The following code shows how to write code in C language:
printf(“Hello, World \n”);
This code consists of instructions for the OS.
A computer executes a collection of instructions i.e. a program which performs specific tasks. The question arises that how should we compare a process in operating system with a program? . We clear this issue by defining that a process is dynamic instance of a computer program.
Algorithm Vs Software:
A well defined task performed by a part of computer program is known as Algorithm.
A collection of computer programs, libraries and related data are referred to as Software.
Process in OS Life Cycle:
Now let us discuss the OS life cycle in detail. A process passes through different states during it’s execution. Different operating systems may differ in case of stages and names of stages because the names are not standardized. If we take a general behavior, a process can reside into one of the following states:
The first state when a process initially starts.
A process is waiting when no processor is free. After some time a processor becomes free. The operating system assigns this waiting process to the free processor. Operating system allocates processors to the ready processes who are waiting for them so the processes can run. There are two possibilities of a process to come in this state:
- Process comes from start state to ready state.
- Interrupted by the scheduler to assign CPU to some other process.
When the operating system scheduler gives a processor to a process, the processor comes into a running state. In this state processor executes the instruction of program.
A process moves to the waiting state when it needs to wait for a resource. If we say the process requires a user input, then process will wait for the user to input something so the process can start execution again.
Terminated or Exit:
Operating system terminates the process after its complete execution. This process moves to exit state where the process then waits for it’s removal from the main memory.
Following figure explains the life cycle of a process,
Process Control Block (PCB):
Process Control Block is a very important topic of operating systems. We can say that it is the vital organ of operating system defined for every process. A data structure is used to define Process Control Block which is maintained by the operating system. An integer process ID i.e. PID is used to identify PCB. A PCB keeps all the information needed to keep track of a process as listed below,
A process can ready, waiting, running etc. The current state of a process is one of these three states and we call it the process state.
These deal with access to resources of system. Process Privileges govern whether to allow or disallow a process the access to it’s resources.
Each process has a unique identity in the operating system. We call it the process ID for that process.
A pointer points towards a parent process.
It is a type of pointer. Program counter points to the next instruction which has to be executed for this process.
For a running state, a process requires a place to be stored for its execution. We call these places “registers”.
CPU Scheduling Information:
A major task which we have to perform is to schedule the process. For this reason we require process priority and other scheduling information.
Memory Management Information:
It has the information about three things i.e. page table, memory limits and Segment table. Their information depends on memory used by operating system.
Process execution, time limits, execution ID etc uses a number of CPU which is included in accounting information.
I/O Status Information:
The process is allocated with the list of I/O devices which is included in I/O status information. We can say that architecture of PCB is totally dependent on operating system. Different operating systems have different information related to architecture. The age of PCB is equal to life cycle of a process.