×

Operating System Tutorial

Operating System Practice

Child Process in Operating System

Child Process in OS: In this tutorial, we will learn about the child process in an operating system and approaches to create a child process. By Monika Jha Last updated : May 06, 2023

What is a Child Process in OS?

One process can create another process, this methodology involves in multitasking Operating System. Here, the process creates another process is called the parent process and the created process is referred to as the child process.

Child process is the subprocess of the main process.

Approaches for creating a child process

There are two approaches for creating a child process:

  1. By using the fork system call (favorable for Unix- like systems and the POSIX standard).
  2. By using the spawn (modern kernel of Microsoft Window).

1. Child created by fork system call

Most of the features of the parent process come into its child process.

For example, file descriptors come into subprocess (child process) from its parent.

In the Unix system, a child process is referred to as the copy of its parent, using the fork system call.

After child process has created, it can be laminated with a different program (using exec system call) as per the requirement.

2. By using the spawn

Spawn is a method by which we can load and execute a new child process. Currently, the running process can wait for the subprocess bring to an end or it can continue on its job.

Any process that is new to the system it requires sufficient memory space that's why parent and its subprocess can execute without any interruption.

Is there any limit to create child process?

Each process can create many sub-processes but each and every child process must have a parent process. If ant process does not have a parent so this indicates it was directly created by the kernel.

In different systems the first process which is init created by the kernel at the time of booting and this kernel created process never terminates.

Some processes which has no parent may be created to carry out various daemon tasks in user space. A way by which a process end up is death (end) of its parent. It leaves its child as a orphan process and with the sum up this process is adopted by init process.

When a child process exits a signal SIGCHLD is sent to the parent of a child process, is interrupted, or resumes after being interrupted. By default the signal is simply ignored.

End of a child process

When a child process ends up its execution or terminates, some data is go back to its parent process.

Whenever a child process ends its execution before the parent has called wait, the kernel has save some information regarding the main process, such as exit status of child, to enable its parent process to call wait later. Because the child is still system resources but not executing it. Such type of process is known as a zombie process. The wait system call is generally held in the SIGCHLD handler.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.