Process vs Parent Process vs Child Process

Computer ScienceMCAOperating System

In Operating System, the fork() system call is used by a process to create another process. The process that used the fork() system call is the parent process and process consequently created is known as the child process.

Details about these are given as follows −

Process

A process is an active program i.e a program that is under execution. It is more than the program code as it includes the program counter, process stack, registers, program code etc. Compared to this, the program code is only the text section.

A process changes its state as it executes. This state partially depends on the current activity of a process. The different states that a process is in during its execution are new, ready, running, blocked, terminated.

A process control block is associated with each of the processes. It contains important information about the process it is associated with such as process state, process number, program counter, list of files and registers, CPU information, memory information etc.

Parent Process

All the processes in operating system are created when a process executes the fork() system call except the startup process. The process that used the fork() system call is the parent process. In other words, a parent process is one that creates a child process. A parent process may have multiple child processes but a child process only one parent process.

On the success of a fork() system call, the PID of the child process is returned to the parent process and 0 is returned to the child process. On the failure of a fork() system call, -1 is returned to the parent process and a child process is not created.

Child Process

A child process is a process created by a parent process in operating system using a fork() system call. A child process may also be called a subprocess or a subtask.

A child process is created as its parent process’s copy and inherits most of its attributes. If a child process has no parent process, it was created directly by the kernel.

If a child process exits or is interrupted, then a SIGCHLD signal is send to the parent process.

A diagram that demonstrates parent and child process is given as follows −

Parent and Child Process

raja
Published on 11-Oct-2018 00:08:44
Advertisements