In the operating system different types of program are being executed like if the program executes in batch then it is known as jobs, if it is executed in the time shared system then it is known as tasks. The process gets created when there is system initialization, user request to create the new process, initialization of the batch jobs, execution of the process etc. The process can be divided into two parts: - Background process and Foreground Process. The background processes are those which run in background without any user interference and multiple processes can be executed at one time while foreground processes are those which are executed by user and only one process can be executed at one time.
Process Structure:-
Process comprise of a certain structure that includes executable code, data required by the program and can be shared data or global data or dynamic data and the state of the program.
Process Control Block:-
Process Control Block (PCB) is also known as task control block. Process control block holds the information of Process state, process control, program counter, CPU scheduling information, CPU registers, memory management information, I/O status information, accounting information.
Process State:-
A process follows certain states and during execution changes the states.
- New State: in this state the process is being created.
- Running State: in this state instructions are executed.
- Waiting State: Process waits for the event.
- Ready State: Process waiting for the processor
- Terminated State: Process finishes the execution.
There are certain processes scheduling queues which are used to execute the processes. Job Queue holds the set of all processes in the system, Ready Queue holds the processes residing in the main memory and waiting for execution, Device Queues holds the processes waiting for the I/O devices. All the processes switch between these queues to get executed.
Context Switching
Context switching means the switching from one process to another process. When the process is in running state its execution state needs to be saved and the execution state of the next process needs to be loaded. The time required to save old process and to load the new one is called context switch time.
Process Creation
There are two processes:- parent process and the child process. Parent process creates the child process which further creates its child and it goes on. The function with which the parent process is divided into child process is called fork(). This function helps when the process is very large and is difficult to execute. This function breaks the larger one into small till the time it gets easy to solve.