• Run The Application With One System Call
  • Managing Address Space When Creating




    Download 6,34 Mb.
    Pdf ko'rish
    bet28/203
    Sana10.01.2024
    Hajmi6,34 Mb.
    #134102
    1   ...   24   25   26   27   28   29   30   31   ...   203
    Bog'liq
    Linux This Book Includes 4 Manuscripts The Underground Bible

    Managing Address Space When Creating
    Processes
    Because the core element of the process is secure address space, it is
    important to solve the problem of allocating it when creating a new
    process. Consider two different approaches.
    System Calls Fork () Exec ()
    In the first approach, the descendant's address space is created as an exact
    copy of the ancestor's address space. This operation is implemented by a
    system call, which is POSIX systems, which is called fork (). In this case,
    not only the address space is copied, but also the counter of the mainstream
    process commands, so after calling fork () the ancestors and descendants


    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.

    Download 6,34 Mb.
    1   ...   24   25   26   27   28   29   30   31   ...   203




    Download 6,34 Mb.
    Pdf ko'rish