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 following below.
1 . Process creation:
- (i). When a new process is created, operating system assigns a unique Process Identifier (PID) to it and inserts a new entry in primary process table.
- (ii). Then the required the required memory space for all the elements of process such as program, data and stack is allocated including space for its Process Control Block (PCB).
- (iii). Next, the various values in PCB are initialized such as,
- Process identification part is filled with PID assigned to it in step (1) and also its parent’s PID.
- The processor register values are mostly filled with zeroes, except for the stack pointer and program counter. Stack pointer is filled with the address of stack allocated to it in step (ii) and program counter is filled with the address of its program entry point.
- The process state information would be set to ‘New’.
- Priority would be lowest by default, but user can specify any priority during creation.
In the beginning, process is not allocated to any I/O devices or files. The user has to request them or if this is a child process it may inherit some resources from its parent.
- (vi). Then the operating system will link this process to scheduling queue and the process state would be changed from ‘New’ to ‘Ready’. Now process is competing for the CPU.
- (v). Additionally, operating system will create some other data structures such as log files or accounting files to keep track of processes activity.
2 . Process Deletion:
Processes are terminated by themselves when they finish’1 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 operation system or by the parent process of P.
A parent may terminate a process due to one of the following reasons,
- (i). When task given to the child is not required now.
- (ii). When child has taken more resources than its limit.
- (iii). The parent of the process is exiting, as a result all its children are deleted. This is called as cascaded termination.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Operating Systems | Input Output Systems | Question 5
- Operating Systems | Process Management | Question 6
- States of a Process in Operating Systems
- Process Table and Process Control Block (PCB)
- Process states and Transitions in a UNIX Process
- Process Scheduler : Job and Process Status
- Difference between Process Image and Multi Thread Process image
- Pass the value from child process to parent process
- Starvation and Aging in Operating Systems
- Need and Functions of Operating Systems
- Static and Dynamic Linking in Operating Systems
- Difference between 32-bit and 64-bit operating systems
- Operating Systems | Set 1
- Operating Systems | Set 2
- Operating Systems | Set 3
- Operating Systems | Set 4
- Operating Systems | Set 5
- Operating Systems | Set 6
- Operating Systems | Set 10
- Operating Systems | Set 7
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.