Process Termination in operating systems

Process Termination in operating systems

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 | types of termination in operating system
Process Termination by Normal Completion
The process completes all tasks and releases the CPU.

Process Termination by Protection Error

The 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.
Process Termination by I/O Failure
When a process attempts to use an I/O device and an 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.

Process Termination by Parent Request

If a parent process request for terminating the child process. Then, the child process should be terminated.

Process Termination by Parent Termination

When the parent is not in the CPU, the child process can’t exist in the CPU. So, when a parent is terminated, the child process also needs to be terminated.

Process Termination due to 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.

Process Termination by Arithmetic Error

There is an instruction of a process that is an invalid instruction, the process needs to be terminated. For example, if a process wants to divide a number by zero.

Process Termination due to Memory Requirement

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 Termination due to Privileged Instruction

Process try to execute an instruction that is reserved for only  OS.

Process Termination by OS Involvement 

In some critical cases, OS takes 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.

Important Questions about Process Termination

What is the orphan process?
An orphan process is a process whose parent process has terminated or finished, but it remains running itself.

What is a zombie process?
The zombie process is a process that has completed its execution but still, its entry remains in the process table.  The term zombie meaning, in general, are the “un-dead person”.
In the operating system, its means un-dead process.

Explain the role of the init process on unix and linux systems in regard to process termination.

Best Answer:
Suppose a process P1 is terminated, now its time when this P1 will move to the zombie state. P1 remains in zombie state until the parent invokes a system call to wait().
When this happened, the process id of P1, as well as the P1 entry in the process table will released.
Now let’s suppose, if a parent does not perform the wait()system call, now the child process will remain in zombie state till the life of parent.
After the death of the parent process, the init process becomes the new parent of the zombie process.

What does cause abnormal process termination in Linux?

The abort() function unblocks the SIGABRT signal, and then abort() function raises that signal for the calling process. This is the main reason for the abnormal termination of the process unless the SIGABRT signal is caught and the signal handler does not return.

Linux process termination re-parenting

In most of the operating systems( just like Unix) when a process becomes orphan then it will be immediately adopted by the special init system process. This is the time when the OS kernel sets the parent to init. This kind of automatically occurring methodology is called re-parenting.

Video Lecture

Types of process termination in os | process termination diagram in os | process creation in os ppt | | process termination in unix ppt | process termination in Linux.