Process Creation and Deletions in Operating Systems

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.

  • The operating system handles process creation by allocating necessary resources and assigning each process a unique identifier.
  • Process deletion involves releasing resources once a process completes its execution.
  • Processes are often organized in a hierarchy, where parent processes create child processes, forming a tree-like structure.

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:

  • Memory is allocated for the program code, data, stack, and the Process Control Block (PCB).

PCB Initialisation:

  • PID and parent PID are stored.
  • CPU registers are set (mostly zero), the stack pointer is set to the stack address, and the program counter is set to the program's entry point.
  • The process state starts as New, then becomes Ready after being added to the scheduler queue.
  • Default priority is assigned unless specified by the user.

Other Structures:

  • OS also prepares supporting files like logs or accounting data for process tracking.

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.

  • The fork() system call creates a copy of the current process, including all its resources, but with just one thread.
  • The exec() system call replaces the current process's memory with the code and data from a specified executable file. It doesn’t return; instead, it "transfers" the process to the new program.
  • The waitpid() function makes the parent process wait until a specific child process finishes executing.
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.

  • CreateProcess() in Windows combines the functionality of both UNIX's fork() and exec(). It creates a new process with its own memory space rather than duplicating the parent process like fork() does. It also allows specifying which program to run, similar to how exec() works in UNIX.
  • When you use CreateProcess(), you need to provide some extra details to handle any changes between the parent and child processes. These details control things like the process’s environment, security settings, and how the child process works with the parent or other processes. It gives you more control and flexibility compared to the UNIX system.

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.
Comment