• Synchronous Implementation Of Processes In Applications
  • 5/3 7 Alerts
  • Linux: This Book Includes 4 Manuscripts. The Underground Bible to the unix operating System with Tools On Security and Kali Hacking to Understand Computer Programming, Data Science and Command Line




    Download 6,34 Mb.
    Pdf ko'rish
    bet34/203
    Sana10.01.2024
    Hajmi6,34 Mb.
    #134102
    1   ...   30   31   32   33   34   35   36   37   ...   203
    Bog'liq
    Linux This Book Includes 4 Manuscripts The Underground Bible

    Waitpid () system call
    You can use the wait () system call to remove process information
    from Linux, but more often use the more versatile version of it
    - waitpid (). This call checks if the control unit of the corresponding process
    is in the system. If it is, and the prz is not in the zombie state ( that is, it is
    still running), then the process in the case of waitpid () will go to
    standby. When the descendant process is completed, the ancestor exits
    standby and removes the descendant control unit. If the ancestor does not
    call waitpid () for the descendant, it may remain in the zombie state for a
    long time.
    Synchronous Implementation Of Processes In Applications
    Let's consider the synchronous execution of processes based on waitpid (). 
    According to POSIX, this system call is defined as:
    # Include < sys /wait. h >
    pid _ t waitpid ( pid _ t pid , // pid of the expected process
    int * status,// descendant completion status information
    int options ); // suppress as 0
    The pid parameter can be set to 0, which means that the process is waiting
    for the same group to which the ancestor belongs, or as –1, which means
    the expectation of any descendant. Here is an example of the
    implementation of synchronous execution with the expectation:
    pid _ t pid ;
    if ((pid = fork ()) == - 1 )
    exit (-1);


    if (pid == 0)
    {
    // descendant - call exec ()
    }
    else
    {
    // ancestor - wait for posterity
    int status;
    waitpid (pid, & status, 0);
    // continue execution
    }
    The status value gives you more information about the completed
    descendant process. There are a number of macros with < sys/wait for .h>:
    WIFEXITED ( status ) - a non-zero value when the descendant
    of a step has completed normally;
    WEXITSTATUS ( status ) - descendant return code (only when
    WIFEXITED ()! = 0).
    The descendant return code is obtained as follows :
    waitpid (pid, & status, 0);
    if (WIFEXITED (status))
    printf (" Descendant ended with code % d \ n", 
    WEXITST A TUS (status));
    5/3 7 Alerts
    In the case of multitasking, there is a need to report processes about events
    occurring in the system or other processes. The simplest mechanism for this
    alert, defined by POSIX , is the alerts . The process after receiving the
    signal immediately responds to his call special functions - a handler  of the
    signal ( signal handler ), or action by default for this signal with each signal


    related to its number, which is unique in the system. No other information
    along with the signal can be transmitted.
    Alarms are the simplest mechanism for interprocess on UNIX systems but
    since they allow the transmission of limited data, they are mainly used for
    event reporting.

    Download 6,34 Mb.
    1   ...   30   31   32   33   34   35   36   37   ...   203




    Download 6,34 Mb.
    Pdf ko'rish

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Linux: This Book Includes 4 Manuscripts. The Underground Bible to the unix operating System with Tools On Security and Kali Hacking to Understand Computer Programming, Data Science and Command Line

    Download 6,34 Mb.
    Pdf ko'rish