will follow the same instruction. The developer must determine which of
the two processes should be managed. This can be done based on the
differences between the fork () return codes for the ancestor and the
descendant .
When the creation of a new process occurs by duplicating the ancestral
address space, there is a need for special means of loading the code into the
address space of the process. Such tools are implemented by a system call,
which is POSIX systems, which is called exec (). As an option to call exec()
must specify the full path to the executable program to be loaded into
memory. In fork () -based systems, in order to run the program, you must
immediately
call
exec
()
after
calling
fork
()
(this
is
called fork + exec technology ).
Run The Application With One System Call
The second approach does not separate address space duplication and code
loading - these steps are combined here into one. In this case, the system
call triggers the specified application to execute (usually it needs to specify
the entire path to the executable file of this application). It is to be divided
into two stages of implementation of the system call:
❖
Allocation of memory ' memory address space under the new
process (with no information from the address space ancestor is not
copied)
❖
Download executable code from the specified file into the
highlighted address spac e
The approach using fork() and exec() is more flexible, as it allows you to
limit yourself to one single step of starting an application if
necessary. Modern operating systems mainly implement a combination of
first and second approaches.