Question: In Sec. 4.8.4, it was pointed out that it would be better to search for holes for the text and data segments separately. Implement this
In Sec. 4.8.4, it was pointed out that it would be better to search for holes for the text and data segments separately. Implement this improvement.
Data from Sec. 4.8.4







The code for exec follows the outline of Fig. 4-40. It is contained in the pro- cedure do_exec (line 18747) in exec.c. After making a few validity checks, the PM fetches the name of the file to be executed from user space (lines 18773 to 18776). Recall that the library procedures which implement exec build a stack within the old core image, as we saw in Fig. 4-38. This stack is fetched into the PM's memory space next (line 18782). The next few steps are written as a loop (lines 18789 to 18801). However, for ordinary binary executables only one pass through the loop takes place. We will first describe this case. On line 18791 a message to the file system switches to the user's directory so the path to the file will be interpreted relative to the user's, rather than to PM's, working directory. Then allowed is called-if execution is allowed it opens the file. If the test fails a negative number is returned instead of a valid file descriptor, and do exit terminates indicating failure. If the file is present and executable, the PM calls read_header and gets the segment sizes. For an ordinary binary the return code from read header will cause an exit from the loop at line 18800. Now we will look at what happens if the executable is a script. MINIX 3, like most UNIX-like operating systems, supports executable scripts. Read_header tests the first two bytes of the file for the magic shebang (#!) sequence and returns a special code if this is found, indicating a script. The first line of a script marked this way specifies the interpreter for the script, and possibly also specifies flags and options for the interpreter. For instance, a script can be written with a first line like
Step by Step Solution
3.43 Rating (153 Votes )
There are 3 Steps involved in it
The following information provides a description of the key functions and concepts related to program execution in the MINIX 3 operating system 1 doexec Purpose This is the main procedure in execc tha... View full answer
Get step-by-step solutions from verified subject matter experts
