fixed rt_thread_exit issue if the current thread has been preempted.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1689 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong 2011-09-01 09:26:45 +00:00
parent e8a462b5c7
commit ed87391097
2 changed files with 12 additions and 19 deletions

View File

@ -1320,8 +1320,9 @@ rt_err_t rt_mb_send_wait (rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout
rt_uint32_t tick_delta;
/* parameter check */
RT_ASSERT(mb != RT_NULL);
RT_ASSERT(mb != RT_NULL);
tick_delta = 0;
RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(mb->parent.parent)));
/* disable interrupt */

View File

@ -218,44 +218,36 @@ rt_err_t rt_thread_startup (rt_thread_t thread)
static void rt_thread_exit()
{
struct rt_thread* thread;
register rt_base_t temp;
/* disable interrupt */
temp = rt_hw_interrupt_disable();
register rt_base_t level;
/* get current thread */
thread = rt_current_thread;
/* disable interrupt */
level = rt_hw_interrupt_disable();
/* remove from schedule */
rt_schedule_remove_thread(thread);
/* change stat */
thread->stat = RT_THREAD_CLOSE;
/* release thread timer */
rt_timer_detach(&(thread->thread_timer));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
/* remove it from timer list */
rt_list_remove(&(thread->thread_timer.list));
rt_object_detach((rt_object_t)&(thread->thread_timer));
if ((rt_object_is_systemobject((rt_object_t)thread) == RT_EOK) &&
thread->cleanup == RT_NULL)
{
rt_object_detach((rt_object_t)thread);
}
#ifdef RT_USING_HEAP
else
{
/* disable interrupt */
temp = rt_hw_interrupt_disable();
/* insert to defunct thread list */
rt_list_insert_after(&rt_thread_defunct, &(thread->tlist));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
}
#endif
/* enable interrupt */
rt_hw_interrupt_enable(level);
/* switch to next task */
rt_schedule();