150 | | It uses two specific fields in the target thread descriptor: the ''join_lock'' field is a remote_spin_lock, and the ''join_xp'' field contains an extended pointer on the first arrived thread. It uses also two specific [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/kern/thread.h#L72 THREAD_FLAG_JOIN_DONE] and [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/kern/thread.h#L73 THREAD_FLAG_KILL_DONE] flags in the target thread descriptor ''flags'' field, and one specific blocking bit [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/kern/thread.h#L86 THREAD_BLOCKED_JOIN], in the ''blocked'' field. |
151 | | |
152 | | * Both the killer thread K, executing the thread_kill() function), and the joining thread J, executing the sys_thread_join() function, try to take the ''join_lock'' implemented in the T thread descriptor (the ''join_lock'' in the J thread is not used). |
| 150 | It uses three specific fields in the target thread descriptor: |
| 151 | * the ''join_lock'' field is a remote_spin_lock. |
| 152 | * the ''join_xp'' field contains an extended pointer on the first arrived thread. |
| 153 | * the ''exit_status'' field is used to transmit the global pointer returned by the terminating thread to the joining thread. |
| 154 | It uses also two specific [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/kern/thread.h#L72 THREAD_FLAG_JOIN_DONE] and [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/kern/thread.h#L73 THREAD_FLAG_KILL_DONE] flags in the target thread descriptor ''flags'' field, and one specific blocking bit [https://www-soc.lip6.fr/trac/almos-mkh/browser/trunk/kernel/kern/thread.h#L86 THREAD_BLOCKED_JOIN], in the ''blocked'' field. |
| 155 | |
| 156 | * Both the killer thread K, (executing the thread_kill() or the thread_exit() function), and the joining thread J (executing the sys_thread_join() function), try to take the ''join_lock'' implemented in the T thread descriptor (the ''join_lock'' in the J thread is not used). |
154 | | * If the FLAG_JOIN_DONE is set, the J thread arrived first and is blocked on the BLOCKED_JOIN condition: the K thread unblocks the J thread from the BLOCKED_JOIN condition (using the ''join_xp'' field in the T thread), reset the JOIN_DONE flag in T thread, releases the ''join_lock'' in T thread, and completes the T thread destruction as described in the detached case. |
155 | | * If the FLAG_JOIN_DONE is not set, the K thread arrived first: the K thread blocks the K thread on the BLOCKED_JOIN condition, sets the FLAG_KILL_DONE in the T thread, registers the killer thread extended pointer in the T thread ''join_xp'' field, releases the ''join_lock'' in the T thread, and deschedules. It completes the T thread destruction as described in the detached case when it is unblocked by the J thread. |
| 158 | * If the FLAG_JOIN_DONE is set, the J thread arrived first and is blocked on the BLOCKED_JOIN condition: the K thread unblocks the J thread from the BLOCKED_JOIN condition (using the ''join_xp'' field in the T thread), reset the JOIN_DONE flag in T thread, registers the exit status in the T thread ''exit_status'' field (only when the K thread is the T pthread itself executing the pthread_exit() function, and finally releases the ''join_lock'' in T thread. It completes the T thread destruction as described in the detached case. |
| 159 | * If the FLAG_JOIN_DONE is not set, the K thread arrived first: the K thread blocks the K thread on the BLOCKED_JOIN condition, sets the FLAG_KILL_DONE in the T thread, registers the exit status in the T thread ''exit_status'' field (only when the K thread is the T pthread itself executing the pthread_exit() function, registers the killer thread extended pointer in the T thread ''join_xp'' field, releases the ''join_lock'' in the T thread, and deschedules. It completes the T thread destruction as described in the detached case when it is unblocked by the J thread. |