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 : |
| 162 | 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()''' or '''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. This synchronization uses the '''term_state''' field in the child process descriptor, that contains the following informations : |
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. |
| 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 main thread scan all children owner descriptors. When it detects that one child terminated, |
| 171 | it 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. |