Process Creation and Deletions in Operating Systems (original) (raw)

Last Updated : 2 Dec, 2025

A process is an instance of a program running, and its lifecycle includes various stages such as creation, execution, and deletion.

**Process Creation

Operating systems like Windows and Linux maintain a parent–child hierarchy of processes. Every new process is created by an already running process using system calls, making the creator the _parent and the newly formed one the _child.

**Steps involved in creating a new process:

**PID Assignment:

The OS gives the new process a unique PID and adds an entry for it in the process table.

**Memory Allocation:

**PCB Initialisation:

**Other Structures:

**Understanding System Calls for Process Creation in UNIX Operating System:

Process creation in many operating systems—especially Unix-like systems—is done using the **fork() system call. ll. When a running process calls fork(), the operating system creates a **new process. The original process becomes the **parent, and the newly created one is the **child.

unix_process_creation

Process creation in Unix

Example:
int pid = fork();
if (pid == 0)
{
/* Child process */
exec("foo");
}
else
{
/* Parent process */
waitpid(pid, &status, options);
}

**Understanding System Calls for Process Creation in Windows Operating System:

In Windows, the system call used for process creation is CreateProcess(). This function is responsible for creating a new process, initializing its memory, and loading the specified program into the process's address space.

**Process Deletion

Processes terminate themselves when they finish executing their last statement, after which the operating system uses the exit() system call to delete their context. Then all the resources held by that process like physical and virtual memory, 10 buffers, open files, etc., are taken back by the operating system. A process P can be terminated either by the operating system or by the parent process of P.

A parent may terminate a process due to one of the following reasons:

  1. When task given to the child is not required now.
  2. When the child has taken more resources than its limit.
  3. The parent of the process is exiting, as a result, all its children are deleted. This is called cascaded termination.

A process can be terminated/deleted in many ways. Some of the ways are:

  1. **Normal termination: The process completes its task and calls an exit() system call. The operating system cleans up the resources used by the process and removes it from the process table.
  2. **Abnormal termination/Error exit: A process may terminate abnormally if it encounters an error or needs to stop immediately. This can happen through the abort() system call.
  3. **Termination by parent process: A parent process may terminate a child process when the child finishes its task. This is done by the using kill() system call.
  4. **Termination by signal: The parent process can also send specific signals like SIGSTOP to pause the child or SIGKILL to immediately terminate it.