@@ -646,6 +646,7 @@ u32 __lwp_thread_init(lwp_cntrl *thethread,void *stack_area,u32 stack_size,u32 p
646646 }
647647 thethread -> stack_size = act_stack_size ;
648648
649+ thethread -> detach_state = LWP_DETACH_STATE_JOINABLE ;
649650 __lwp_threadqueue_init (& thethread -> join_list ,LWP_THREADQ_MODEFIFO ,LWP_STATES_WAITING_FOR_JOIN ,0 );
650651
651652 memset (& thethread -> context ,0 ,sizeof (thethread -> context ));
@@ -720,14 +721,16 @@ void __lwp_thread_exit(lwp_cntrl *thethread,void *value_ptr)
720721
721722 __lwp_thread_dispatchdisable ();
722723 thethread -> wait .ret_arg = value_ptr ;
723- if ((p = __lwp_threadqueue_dequeue (& thethread -> join_list ))) {
724- do {
725- * (void * * )p -> wait .ret_arg = value_ptr ;
726- } while ((p = __lwp_threadqueue_dequeue (& thethread -> join_list )));
727- } else {
728- __lwp_thread_setstate (thethread ,LWP_STATES_WAITING_FOR_JOINATEXIT );
729- __lwp_thread_dispatchenable ();
730- __lwp_thread_dispatchdisable ();
724+ if (thethread -> detach_state == LWP_DETACH_STATE_JOINABLE ) {
725+ if ((p = __lwp_threadqueue_dequeue (& thethread -> join_list ))) {
726+ do {
727+ * (void * * )p -> wait .ret_arg = value_ptr ;
728+ } while ((p = __lwp_threadqueue_dequeue (& thethread -> join_list )));
729+ } else {
730+ __lwp_thread_setstate (thethread ,LWP_STATES_WAITING_FOR_JOINATEXIT );
731+ __lwp_thread_dispatchenable ();
732+ __lwp_thread_dispatchdisable ();
733+ }
731734 }
732735 __lwp_thread_close (thethread );
733736 __lwp_thread_dispatchenable ();
0 commit comments