Open In App

Process Creation and Deletions in Operating Systems

Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite – States of a Process in Operating Systems 

There are two basic operations that can be performed on a process: Creation and Deletion. They are explained as 

Process creation: 

1. When a new process is created, the operating system assigns a unique Process Identifier (PID) to it and inserts a new entry in the primary process table. 

2. Then required memory space for all the elements of the process such as program, data, and stack is allocated including space for its Process Control Block (PCB). 

3. Next, the various values in PCB are initialized such as, 

  1. The process identification part is filled with PID assigned to it in step (1) and also its parent’s PID.
  2. The processor register values are mostly filled with zeroes, except for the stack pointer and program counter. The stack pointer is filled with the address of the stack-allocated to it in step (ii) and the program counter is filled with the address of its program entry point.
  3. The process state information would be set to ‘New’.
  4. Priority would be lowest by default, but the user can specify any priority during creation.

4. Then the operating system will link this process to the scheduling queue and the process state would be changed from ‘New’ to ‘Ready’. Now the process is competing for the CPU. 

5. Additionally, the operating system will create some other data structures such as log files or accounting files to keep track of processes activity. 

Process Deletion: 

Processes are terminated by themselves when they finish executing their last statement, then operating system USES exit( ) system call to delete its 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.

Last Updated : 08 Aug, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads