Changes between Version 94 and Version 95 of processus_thread


Ignore:
Timestamp:
Apr 29, 2018, 2:42:14 PM (3 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • processus_thread

    v94 v95  
    154154== __6) Process destruction__ ==
    155155
    156 The destruction of a process P can be caused by a sys_exit() system call executed by the main thread of process P,  or by another process executing the sys_kill(SIGKILL) system call. It can also be caused by a CtrlC signal typed on the process terminal. In all cases, the work must be done for all process copies in all clusters, using the list of copies rooted in the owner cluster.
     156The destruction of a process P can be caused by a sys_exit() system call executed by any thread of process P,  or by another process executing the sys_kill(SIGKILL) system call. It can also be caused by a CtrlC signal typed on the process terminal. In all cases, the work must be done for all process copies in all clusters, using the list of copies rooted in the owner cluster.
    157157
    158158=== 6.1) parent / children synchronization
     
    160160The process descriptors copies (other than the process descriptor in owner cluster) are simply deleted by the scheduler when the last thread of a given process in a given cluster is  deleted. The process descriptor copy is removed from the list of copies in the owner process cluster descriptor, and the process copy disappears.
    161161
    162 But the process destruction in the owner cluster is more complex, because the child process destruction must be reported to the parent process when the parent process executes the blocking sys_wait() system call. Therefore, the child process destruction cannot be done before the parent calls the sys_wait() function. As the '''sys_wait()''' function, and the '''sys_kill() / sys_exit()''' function are executed by different threads running in different clusters, this requires a parent/child synchronization:
    163 After a sys-kill() or sys_exit(), the process descriptor in owner cluster is kept in ''zombi'' state :  the main thread (i.e. thread 0 in process owner cluster) is not deleted until the sys_wait() syscall is executed by the parent process.  The synchronization uses the '''term_state'''  field in the child process descriptor, that contains the following informations :
     162The process destruction in the owner cluster is more complex, because the child process destruction must be reported to the parent process when the parent process executes the blocking sys_wait() system call. Therefore, the child process destruction cannot be done before the parent calls the sys_wait() function. As the '''sys_wait()''' function, and the '''sys_kill()''' or '''sys_exit()''' function are executed by different threads running in different clusters, this requires a parent/child synchronization:
     163After a sys-kill() or sys_exit(), the process descriptor in owner cluster is kept in ''zombi'' state :  the main thread (i.e. thread 0 in process owner cluster) is not deleted until the sys_wait() syscall is executed by the parent process.  This synchronization uses the '''term_state'''  field in the child process descriptor, that contains the following informations :
    164164 * the PROCESS_FLAG_KILL  indicates that a KILL request has been received by the child; 
    165165 * the PROCESS_FLAG_EXIT indicates that an EXIT  request has been made by the child; 
     
    168168 * moreover, for an exit(),  the exit() argument  is registered in this ''term_state'' field.
    169169
    170 The actual deletion of the process descriptor in owner cluster is done by the sys_wait() function, that must be executed by the parent main thread (i.e. thread 0 in parent owner cluster). This sys_wait() function executes an infinite loop. At each iteration the parent scan all children owner descriptors. When it detects that one child terminated,
    171 it set the PROCESS_FLAG_WAIT in child descriptor, set the THREAD_FLAG_DELETE in the child main thread, and exit to report the child termination state to parent process. It is the responsibility of the parent process to re-enter the sys_wait() syscall for the other children. When the parent process does not detect a terminated child at the end of an iteration, it deschedules without blocking. 
     170The actual deletion of the process descriptor in owner cluster is done by the sys_wait() function, that must be executed by the parent main thread (i.e. thread 0 in parent owner cluster). This sys_wait() function executes an infinite loop. At each iteration the parent main thread scan all children owner descriptors. When it detects that one child terminated,
     171it set the PROCESS_FLAG_WAIT in child process descriptor, set the THREAD_FLAG_DELETE in the child main thread, and returns to report the child termination state to parent process. It is the responsibility of the parent process to re-enter the sys_wait() syscall for the other children. When the parent process does not detect a terminated child at the end of an iteration, it deschedules without blocking. 
    172172
    173173