Process termination is a technique in which a process is terminated and release the CPU after completing the execution.
Most of the OS use exit( ) system call to terminate a process.
Main causes of process termination
The process completes all task and releases the CPU.
Process wants to use a resource that is not allowed to use by that process. For example; If a process wants to WRITE on a file that is READ ONLY file.
When a process attempts to use an I/O device and I/O device is not working fine at the moment. For example, a process that wants to print a file on the printer, but the printer is defective.
If a parent process request for terminating the child process. Then, child process should be terminated.
When the parent is not in CPU, child process can’t exist in CPU. Soo when a parent is terminated, child process also needs to be terminated.
Time Over Run:
Waiting time is specified for a process that for how much time a process can wait for a resource. In this time if the process fails to allocate a resource then the process needs to be terminated.
There is an instruction of a process that is invalid instruction, the process needs to be terminated. For example, if a process wants to divide a number by zero.
A process requires more memory to execute but the system fails to provide enough memory to the process for its execution, then the process needs to be terminated.
Process try to execute an instruction that is reserved for only OS.
OS Involvement to terminate:
In some critical cases, OS take the control of the process and stops the execution of the process. For example, if a deadlock occurs, or deadlock can occur, then OS terminates the process.