Changes between Version 86 and Version 87 of processus_thread


Ignore:
Timestamp:
Mar 1, 2018, 1:24:45 PM (4 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • processus_thread

    v86 v87  
    120120== __5) Thread destruction__ ==
    121121
    122 The destruction of an user thread T can be caused by another thread K, executing  the ''pthread_cancel()'' sys call requesting the target thread T to stop execution. It can be caused by the thread T itself, executing the ''pthread_exit()'' sys call to suicide. Finally, it can be caused by the ''exit()'' or ''kill()'' syscalsl requesting the destruction of all threads of a given process.   
     122The destruction of an user thread T can be caused by another thread K, executing  the ''pthread_cancel()'' sys call requesting the target thread T to stop execution. It can be caused by the thread T itself, executing the ''pthread_exit()'' sys call to suicide. Finally, it can be caused by the ''exit()'' or ''kill()'' syscalls requesting the destruction of all threads of a given process.   
    123123
    124 The unique method to destroy a thread is to call the '''thread_kill()''' function, that set the THREAD_FLAG_REQ_DELETE in the ''flags'' field of the target thread descriptor. The thread will be asynchronously deleted by the scheduler at the next scheduling point,
     124The unique method to destroy a thread is to call the '''thread_kill()''' function, that set the THREAD_FLAG_REQ_DELETE bit in the ''flags'' field of the target thread descriptor. The thread will be asynchronously deleted by the scheduler at the next scheduling point,
    125125that calls the ''thread_destroy()'' function. This function detach the thread from the scheduler, detach the thread from the local process descriptor, and releases the memory allocated to the thread descriptor. The '''thread_kill(''') function can be called by the ''target'' thread itself (for an exit), or it can be done by another ''killer'' thread (for a kill).
    126126
    127 The main thread (i.e. the thread 0 in the process owner cluster) is a special case, because the main thread of a given process can only be deleted (i.e. marked for delete) by the parent process main thread executing the sys_wait() scale (see section [6] below).   
     127The main thread (i.e. the thread 0 in the process owner cluster) is a special case, because the main thread of a given process can only be deleted (i.e. marked for delete) by the parent process main thread executing the ''sys_wait()'' syscall (see section [6] below).   
    128128
    129129=== 5.1) thread running in DETACHED mode ===
    130130
    131 The scenario is rather simple when the target thread is not running in ATTACHED mode.
     131The scenario is rather simple when the target thread T is not running in ATTACHED mode.
    132132The killer thread (that can be the target thread itself for an exit) call the thread_kill() function that does the following actions: 
    133133 * the killer thread  sets the THREAD_BLOCKED_GLOBAL bit in the target thread ''blocked'' field,
    134134 * the killer thread sets the THREAD_FLAG_REQ_DELETE bit in the target thread ''flags'' field,
    135135 * the killer thread returns without waiting the actual deletion.
    136 
    137 
    138 
    139 #######
    140 and registers in the target thread ''ack_rsp_count'' field a pointer on the location where the acknowledge must be written.
    141  * If the target thread is running on another core than the killer thread, the killer thread send an IPI to the core running the target thread, to ask the target scheduler to handle the request. If the target is running on the same thread as the killer, the killer thread calls directly the sched_handle_signal() function.
    142  * In both cases, the sched_handle_signals() function - detecting the SIG_KILL signal - detach the target thread from the scheduler, detach the target thread from the local process descriptor, detach the target thread from the parent thread if it is attached, release the memory allocated to the target thread descriptor, and atomically decrement the response counter in the killer thread to signal completion.
    143 #######
    144136
    145137=== 5.2) thread running in ATTACHED mode ===