线程由就绪态变为挂起态,不是先将进程PCB从就绪队列中删除,再插入阻塞队列吗?我有看到从就绪队列移除的函数代码,那么插入阻塞队列的代码在哪里呢?请看代码:
rt_err_t rt_thread_suspend(rt_thread_t thread)
{
register rt_base_t temp;
/* thread check */
RT_ASSERT(thread != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s
", thread->name));
if (thread->stat != RT_THREAD_READY)
{
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: thread disorder, %d
",
thread->stat));
return -RT_ERROR;
}
/* disable interrupt */
temp = rt_hw_interrupt_disable();
/* change thread stat */
thread->stat = RT_THREAD_SUSPEND;
rt_schedule_remove_thread(thread);
/* stop thread timer anyway */
rt_timer_stop(&(thread->thread_timer));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
return RT_EOK;
}
查看更多