 Hello everyone, my name is Sir F. R. Syed from CSE department WIT, Saulapur. The topic for my today's lecture is process creation in UNIX operating system of the learning outcome. At the end of the session, the students will be able to describe how a new process is created in UNIX operating system. Let us first see what is a process. Now, a process in simple terms is nothing but an instance of a running program. The only way for a user to create a new process in the UNIX operating system is to invoke a system called which is nothing but the fork system called. Now, there are two types of processes that we are going to discuss. The first one is the parent process and the second one is the child process. Now the process that invokes the fork system call is called as the parent process and during this time the newly created process is called as the child process. Now this is the syntax for the fork system call PID equal to fork. Now in the parent process PID is the child process ID whereas in the child process the PID is 0. Now we have another type of a process, process 0 which is created internally by the kernel when the system is booted and this process 0 is the only process which is not created via the fork system call. Now let us see the sequence of operations for the fork system call. The kernel allocates a slot in the process table for the new process. Then it assigns a unique ID number to the child process and it makes a logical copy of the context of the parent process. Then it increments the file and the inode table counters for the files associated with the process. It then returns the ID number of the child to the parent process and a 0 value to the child process. Now let us see the fork algorithm, the input is nothing given to it whereas the output is to the parent process the child PID number is returned whereas to the child process 0 is returned. Now what are the steps in it? First of all it checks for the available kernel resources then it gets the free process table slot unique PID number. It then checks that the user is not running too many processes and marks the child state as being created. Then copies the data from the parent process table slot to the new child slot. Then it increments the counts on current directory inode and the changed root. Then it increments the open file counts in the file table. Then makes a copy of parent context that is you area text data stack etc in memory. Then push the dummy system level context layer on to the child system level context. Now if the executing process is a parent process then what thing is done? The child state is changed to the ready to run and the child ID is returned from the system to the user otherwise that is else it is concluded that the executing process is the child process. Then initialize the U area timing fields and then return to 0 to the user and in this way the algorithm terminates. Now the students are expected to think and write the answer to the following question. The students are expected to pause the video and write the answer for the following question. Name the process which is not created using the fork system call. Also tell when is that process created. Now pause the video and write your answer. Now let us see the answer to the question that was asked. The question was name the process created using fork system call and when is it created? The answer is the process 0 which is not created using the fork system call. It is created internally by the kernel when the system is booted. So thus the process 0 being the only process which is not created via the fork system call. Now let us see the fork creating a new process context. As we can see in the diagram we have to the right the file table and the inode table and to the left we have the parent process and the child process and we have some shared text between the processes and to individual process we have the data. Now for example in the parent process we have the parent data the parent user stack. Similarly in the child process we have the child data and the child user stack. Also in both the cases we have per process region table for the child process and the parent process. And lastly there is some u area and kernel stack for both the child as well as the parent process. Inside the u area we have the open files, the current directory and the change root data. You will see somewhat the description about this. The figure shows the logical view of the parent and the child processes and the relationship to the other kernel data structures. Now both the processes share files that the parent had open at the time of the fork system call. Now the file table reference count for those files is one greater than it had been. Now the child process has the same current directory and changed root if applicable as the parent. Now the inode reference count of those directories is one greater than it had been. The processes have identical copies of the text, the data and the user stack regions. The region type and the system implementation determine whether the processes can share a physical copy of the text region. This is the reference used for the video lecture, the design of Unix operating system book by Morris J. Bash. Thank you.