Process in Unix? Mechanism of Process creation in Unix? Process states and transition with diagram?
A process is simply a running program. A process is said to be born when the program starts execution and remains alive till the process is active. After the execution the process is said to be died.
A process in a Unix system is created by fork system call. Every process except process 0 is created. The process that invokes the fork system call is parent process and the newly created process is the child process.
Every process has one parent process but a parent can have many child process. The kernel identifies it process by its process identification number (PID). Process 0 is a special process created "by hand" when the system boots.
There are 3 distinct phase in mechanism of process creation and uses 3 system calls: fork(), exec() and wait().
fork(): Creates a child process. A new process is created because an existing process creates an exact copy of itself. This child process has the same environment as its parent but only the PID is different. This procedure is known as forking.
exec(): After forking the process, the address space of the child process is overwritten by the new process data. This is done through exec call to the system. No new process is created over here. The PID & PPID remains unchanged.
wait(): The parent then executes wait system call to wait for the child process to complete its execution.
The important attributes that are inherited by the child process from its parents are: Real UID and GID, PGID, Nice value, Environment setting, Current working directory, memory segments etc.
When the process dies it immediately moves to the zombie state and remains in that state until the parent picks it up to exit status. A zombie is the harmless dead child.
When a child dies kernel send SIGCHLD signal to parent for information. It is also possible for the parent to die before child dies. The child then becomes an orphan process and kernel makes 'init' parent of all the orphans. When this adopted child dies 'init' picks up it to exit status
Process States & Transition Diagram
The life time of a process is divided into the states that describe the process as per the following:
1) Process is executing in the user mode.
2) Process is executing in the kernel mode.
3) Process is not executing but its ready to run as kernel schedules it.
4) Process is sleeping & reside in memory
5) Process is ready to run but swapper must swap the process into the memory.
6) Process is sleeping & the swapper swap the process into secondary storage.
7) Process is returning from kernel to user mode.
8) Process is newly created & runs in a transition state.
9) Process executes the exit system call & moves to zombie state.
Zombie state is the final state of the process.
Wonderful.
ReplyDeleteIt is so helpfull😀
And most beneficial ....
Great job.it is easy to understand
ReplyDeleteTq bro
ReplyDeleteTq u sooo much sir.. really it's more helpful for me....❤️
ReplyDelete