Changes between Version 90 and Version 91 of processus_thread


Ignore:
Timestamp:
Mar 2, 2018, 10:06:37 AM (6 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • processus_thread

    v90 v91  
    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()'' syscalls requesting the destruction of all threads of a given process.   
     122The destruction of a target 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
    124124The 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,
    125 that 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).
     125that 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 by another 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()'' syscall (see section [6] below).   
     127If the target thread is running in attached mode, the '''thread_kill()''' function synchronize with the joining thread, waiting the actual execution of the pthread_join() syscall before marking the target thread for delete.
     128
     129If the target thread is main thread (i.e. the thread 0 in the process owner cluster) the  '''thread_kill()''' does not mark the target thread for delete, because this must be done by the parent process main thread executing the ''sys_wait()'' syscall (see section [6] below).   
    128130
    129131=== 5.1) thread running in DETACHED mode ===
     
    150152   * If the FLAG_KILL_DONE is set, the K thread arrived first and is blocked on the BLOCKED_JOIN condition: the J thread unblocks the killer thread, reset the FLAF_KILL_DONE in the T thread, releases the "join_lock" in T thread, and returns.
    151153   * If the FLAG_KILL_DONE is not set, the J thread arrived first: the J thread register its extended pointer in the T thread "join_xp" field, set the FLAG_JOIN_DONE in the T thread, sets the BLOCKED_EXIT bit in the J thread, releases the "join_lock" in the T thread, and deschedules. It simply returns when it is unblocked by the K thread.
     154
     155=== 5.3) main thread destruction ===
    152156
    153157== __6) Process destruction__ ==