 Hello everyone, myself Mr. F. R. Syed. I work as an assistant professor in the department of computer science and engineering at Walsh Institute of Technology, Soulapur. The topic for my today's lecture is invoking executable file in Unix system. So, now the learning outcome at the end of the session, the students will be able to describe the process of invoking executable file in Unix system. Now the EXCC system call invokes another program overling the memory space of a process with a copy of an executable file. Now contents of user-level context that existed before the EXCC system call are no longer accessible afterwards except for the EXCC's parameters which kernel copies from old address space to the new address space. Now we have as following the syntax for the system call EXCCVE into bracket file name comma ARGV comma ENVP where file name is the name of the executable file being invoked. ARGV is a pointer to an array of character pointers that are parameters to the executable program and ENVP is a pointer to an array of character pointers that are the environment of the executed program. Now there are several library functions that call the EXCC system call such as EXECV, EXECLE and so on. All these call EXCCVE eventually hence it is used here to specify the EXCC system call. Now when a program uses command line parameters as in main into bracket ARGC comma ARGV the array ARGV is a copy of the ARGV parameter to EXCC. The character strings in the environment are of the form name equal to value and may contain useful information for programs such as users home directory and a path of directories to search for the executable programs. Now processes can access their environment via the global variable Environ initialized by the C start up routine. So now we have the algorithm for EXCC system call which takes as input three things the file name, the parameter list and the environment variables list. Now let us see what it does. It first accesses the file via the algorithm name I to determine if it is an executable regular that is non-directly file and to determine if the user has the permission to execute the program. The kernel then reads the file header to determine the layout of the executable file. Then read the file headers and check that it is a load module. It then copies the EXCC parameter from old address space to the system space. And then for every region attached to the process, it detaches all the old regions using the algorithm detached. And then for every region specified in the load module, it allocates new regions using the algorithm aloc reg. Then it attaches the region using algorithm attach reg. Then loads the region into memory. If it is appropriate using algorithm load reg. And after this it copies the EXCC parameters into the new user stack region. And then special processing is done for the set UID programs tracing. And then initialize the user register save area for return to the user mode. And finally release the inode of the file using the algorithm I put. Okay. So now the students are expected to think and write the answer to the following question. Name the different algorithms that are invoked during the execution of the EXCC system call. So now pause the video and write your answer. Okay. So the answer is we have the following different algorithms that are called during the execution of the EXCC system call. First one is the algorithm name I to get the file I node. The next is the algorithm detach reg to detach all the old regions. The next algorithm is alloc reg to allocate the new regions. Next is the algorithm attach reg to attach the regions. Then the algorithm load reg to load the region into memory. And finally the algorithm I put to release the inode of the file. Okay. Next we have the image of an executable file. The figure shows the logical format of an executable file as it exists in the file system that is typically generated by the assembler or the loader. It actually consists of four parts. You'll see the four parts. The first is the primary header. It describes how many sections are there in the file. The start address for the process execution and the magic number which gives the type of the executable file. Then the second one is the section headers which describe each section in the file giving the section size, the virtual addresses the section should occupy when running in the system and other such information. Then the third one is the sections which contain the data such as text that are initially loaded in the process address space. And finally at the end we have the fourth one that is some miscellaneous information which may contain symbol tables and other data that may be useful for the purpose of debugging. Specific formats have evolved through the years but all the executable files have contained a primary header with a magic number. The magic number is a short integer that identifies the file as a load module and enables the kernel to distinguish the run time characteristics about it. Okay, so next we see an example of the EXCC system call. Here it creates a child process that invokes the EXCC system call. Immediately after the parent and the child processes return from the fork, they execute independent copies of the program. When the child process is about to invoke the EXCC call, its text region consists of the instructions for the program, its data region consists of the strings that is slash bin slash date and date and its stack will contain the stack frames the process pushed to get to the EXCC call. The kernel finds the file slash bin slash date in the file system then finds that all users can execute it and determines that it is actually an executable load module. By convention the first parameter of the argument list ARGV to the EXCC is the last component of the path name of the executable file. The process thus has the access to the program name at user level. The kernel will then copy the strings slash bin slash date and date to an internal holding area and freeze the text, data and the stack regions that are occupied by the process. The kernel then reconstructs the original parameter list and puts it in the stack region. After the EXCC call, the child process no longer executes the old program but it executes the program date. When the date program completes, the parent process receives its exit status from the weight system call. So next we see what are the advantages for keeping text and data separate. Now there are actually two advantages for keeping text and data separate. So if text and data were in the same region then in that case the system could not prevent a process from overwriting its instructions because it would not know which addresses contain instructions and which contain the data. But if text and data are in separate regions, the kernel can set up hardware protection mechanisms to prevent the processes from overriding their text space. In that case if a process mistakenly attempts to override its text space then it incurs a protection fault that typically results in termination of the process. So the first advantage is actually avoiding overwriting of instructions. We have one more advantage that is the second advantage of having separate regions for text and data is to allow sharing of regions. If a process cannot write its text region, its text does not change from the time the kernel loads it from the executable file. If several processes execute a file they can therefore share one text region saving memory. Thus when the kernel allocates a text region for a process in exeC it checks if the executable file allows its text to be shared indicated by its magic number. If so it follows the algorithm Zaloc to find an existing region for the file text or to assign a new one. This is the reference used for the video lecture. Thank you.