Changes between Version 105 and Version 106 of processus_thread
- Timestamp:
- Aug 22, 2018, 6:01:44 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
processus_thread
v105 v106 127 127 The destruction of a target thread T can be caused by another thread K, executing the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/syscalls/sys_thread_cancel.c pthread_cancel()] syscall requesting the target thread T to stop execution. It can be caused by the thread T itself, executing the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/syscalls/sys_thread_exit.c pthread_exit()] syscall to suicide. Finally, it can be caused by the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/syscalls/sys_exit.c exit()] or [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/syscalls/sys_kill.c kill()] syscalls requesting the destruction of all threads of a given process. 128 128 129 The unique method to destroy a thread is to call the '''thread_ kill()''' function, that sets 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.130 The scheduler calls the ''thread_destroy()'' function that detaches the thread from the scheduler, detaches 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).129 The unique method to destroy a thread is to call the '''thread_delete()''' function, that sets 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. 130 The scheduler calls the ''thread_destroy()'' function that detaches the thread from the scheduler, detaches the thread from the local process descriptor, and releases the memory allocated to the thread descriptor. The '''thread_delete()''' function can be called by the target thread itself (for an exit), or by another thread (for a kill). 131 131 132 If the target thread is running in attached mode, the '''thread_ kill()''' function synchronizes with the joining thread, waiting the actual execution of the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/syscalls/sys_thread_join.c pthread_join()] syscall before marking the target thread for delete.132 If the target thread is running in attached mode, the '''thread_delete()''' function synchronizes with the joining thread, waiting the actual execution of the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/syscalls/sys_thread_join.c pthread_join()] syscall before marking the target thread for delete. 133 133 134 If the target thread is the 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).134 If the target thread is the main thread (i.e. the thread 0 in the process owner cluster) the '''thread_delete()''' does not mark the target thread for delete, because this must be done by the parent process main thread executing the [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/syscalls/sys_wait.c wait()] syscall (see section [6] below). 135 135 136 136 === 5.1) Thread running in DETACHED mode ===