Merge pull request #2329 from RT-Thread/fix_pthread

[ptherad] Fix pthread_exit issue
This commit is contained in:
Bernard Xiong 2019-02-14 16:34:34 +08:00 committed by GitHub
commit 65b7f438ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 13 deletions

View File

@ -346,12 +346,6 @@ void pthread_exit(void *value)
ptd->tls = RT_NULL; ptd->tls = RT_NULL;
} }
if (ptd->attr.detachstate == PTHREAD_CREATE_JOINABLE)
{
/* release the joinable pthread */
rt_sem_release(ptd->joinable_sem);
}
/* detach thread */ /* detach thread */
rt_thread_detach(ptd->tid); rt_thread_detach(ptd->tid);
/* reschedule thread */ /* reschedule thread */

View File

@ -347,17 +347,17 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
/* change stat */ /* change stat */
thread->stat = RT_THREAD_CLOSE; thread->stat = RT_THREAD_CLOSE;
/* detach object */ if ((rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE) &&
rt_object_detach((rt_object_t)thread); thread->cleanup == RT_NULL)
{
if (thread->cleanup != RT_NULL) rt_object_detach((rt_object_t)thread);
}
else
{ {
/* disable interrupt */ /* disable interrupt */
lock = rt_hw_interrupt_disable(); lock = rt_hw_interrupt_disable();
/* insert to defunct thread list */ /* insert to defunct thread list */
rt_list_insert_after(&rt_thread_defunct, &(thread->tlist)); rt_list_insert_after(&rt_thread_defunct, &(thread->tlist));
/* enable interrupt */ /* enable interrupt */
rt_hw_interrupt_enable(lock); rt_hw_interrupt_enable(lock);
} }
@ -366,7 +366,6 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
} }
RTM_EXPORT(rt_thread_detach); RTM_EXPORT(rt_thread_detach);
#ifdef RT_USING_HEAP #ifdef RT_USING_HEAP
/** /**
* This function will create a thread object and allocate thread object memory * This function will create a thread object and allocate thread object memory