Executable Files
Chapter 1 defined a process as an “execution context.” By this we mean the collection of information needed to carry on a specific computation; it includes the pages accessed, the open files, the hardware register contents, and so on. An executable file is a regular file that describes how to initialize a new execution context (i.e., how to start a new computation).
Suppose a user wants to list the files in the current directory;
he knows that this result can be simply achieved by typing the filename
of the /bin/ls [*] external command at the shell prompt. The command shell
forks a new process, which in turn invokes an execve( )
system call (see the section "The exec Functions" later in
this chapter), passing as one of its parameters a string that includes
the full pathname for the ls
executable file—/bin/ls, in this
case. The sys_execve( )
service
routine finds the corresponding file, checks the executable format, and
modifies the execution context of the current process according to the
information stored in it. As a result, when the system call terminates,
the process starts executing the code stored in the executable file,
which performs the directory listing.
When a process starts running a new program, its execution context changes drastically because most of the resources obtained during the process’s previous computations are discarded. In the preceding example, when the process starts executing /bin/ls, it replaces the shell’s arguments with new ones ...
Get Understanding the Linux Kernel, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.