Changes between Version 49 and Version 50 of processus_thread


Ignore:
Timestamp:
Dec 7, 2017, 1:04:28 AM (7 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • processus_thread

    v49 v50  
    124124== __5) Thread destruction__ ==
    125125
    126 The destruction of a thread T running in cluster K can be caused by the thread itself, with the pthread_exit() system call. It can also be caused by a kill signal, sent by another thread,  requesting the thread to stop execution. In both case, the host kernel K is in charge of the destruction. The scenario is more complex if the finishing thread T is running in ATTACH mode, because the parent thread TP must be informed of the completion of thread T, in case of pthread_join() executed by TP.
     126The destruction of a thread T running in cluster K can be caused by the thread itself, executing the thread_exit() function. It can also be caused by another thread, executing the thread_kill() requesting the target thread to stop execution. In both case, the host kernel K is in charge of the destruction. The scenario is more complex if the finishing thread T is running in DETACHED mode, because the parent thread TP must be informed of the completion of thread T, in case of pthread_join() executed by TP.
    127127
    128 === 5.1) phase 1 ===
     128=== 5.1) thread_exit ===
    129129
    130 It T is running in ATTACH mode, the host cluster K force the T state to ZOMBI, to prevent the thread to be scheduled. If the thread completion is caused by an exit, the thread T stops immediately execution. If it is caused by a kill signal, the signal is registered in the thread descriptor, and the rescheduling will only occur at the next scheduling point.
    131 If T is not running in attached mode, the scenario is similar, but the T is directly forced to the DEAD state.
     130 * If T is running in DETACHED mode, the calling thread T sets the FLAG_SUICIDE bit in the "flags" bit_vector, registers the BLOCKED_GLOBAL bit in the "blocked" bit_vector, and de-schedule. The scheduler, detecting the FLAG_SUICIDE bit, remove the thread from the scheduler list, remove the thread from its process, and destroys the thread descriptor.
     131 * If it is running in ATTACHED mode, the calling thread T sets the BLOCKED_EXIT bit in the "blocked" bit vector and de-schedule.  The FLAG_KILL bit in the "flags" bit-vector,  and the BLOCKED_EXIT bit are set by the parent thread TP (using remote  accesses) when it executes the pthread_join(), and detects the BLOCKED_EXIT bit in thread T. The scenario is the standard kill described below.
    132132
    133 === 5.2) phase 2 ===
     133=== 5.2) thread_kill ===
    134134
    135 This second phase is only required, in the parent thread cluster M, if T is running in ATTACH mode. The parent thread descriptor maintains a global list of all children threads running in ATTACH mode. When the parent thread execute the pthread_join() system call for a child identified by its TRDID, the M kernel scan this list to localize the selected child thread, and directly poll the child thread status using a remote_read access. When the M kernel detects the completion of T (ZOMBI state), it send a RPC_THREAD_USER_JOIN to the K cluster containing the T thread to ask the K kernel to change the state of T from ZOMBI to DEAD.   
     135This is a three steps scenario:
     136
     137 1. The killer thread uses a remote access to set the BLOCKED_GLOBAL bit in the target thread "blocked" bit_vector, set the FLAG_KILL bit in the target thread "signals" bit_vector, and send an IPI to the target thread core to force scheduling.
     138 1. The target thread scheduler, detecting the FLAG_KILL bit set, removes the thread from the scheduler list, and reset the FLAG_KILL bit to acknowledge the killer.
     139 1. The killer thread poll the FLAG_KILL bit in the target thread until reset, detach the thread from its parent if the thread is attached, and destroys the target thread, using a RPC_THREAD_DESTROY if the target thread is remote.
     140
     141
    136142
    137143=== 5.3) phase 3 ===