When Unix is started, the kernel ‘kick-starts’ process generation by creating an initial process with an process-id (PID) of O and hence oft...
When Unix is started, the kernel ‘kick-starts’ process generation by creating an initial process with an process-id (PID) of O and hence often referred to as process 0 sched, since it is responsible for process scheduling.
- In some systems process 0 is called as swapper which is responsible for memory management responsible for memory management.
- Another function of process 0 is to spawn another process, with an PID of 1, which is called process1 or Init. Init is ancestor of all other processes in the system.
- Init is responsible for users login & initiate their own processes.
- Getty is a process one for each process which monitor the terminal.
- When user try to login getty runs a login process, starts a shell process for the user.
- The processes to be activated by init are specified in a file called /etc/init tab. Subsequently the shell may spawn further process on the request of the user.
When the user logs out init will re-spawn getty to coninue ot monitor the terminal. Init will generally also spawn other processes called daemons, which are not associated with individual users but continuously unattached to attend to certain system administration functions such as line printer. Spooling, monitoring network activity etc.
Creation of new process in Unix involves two system calls namely fork & exec.
- Fork will create a copy of the calling process. Hence after execution processes running.
- The exec is to load another program which replaces the original code of child process in memory. The fork system call returns a value which for the child process is 0 and for the parent process is the new PID of the child process.