/* This function is the timeout function for thread, normally which is invoked when thread is timeout to wait some resource.  */
static void _thread_timeout(void *parameter)
/* This function is the timeout function for thread, normally which is invoked when thread is timeout to wait some resource.  */
static void _thread_timeout(void *parameter)
{
    struct rt_thread *thread;
    rt_base_t level;
    thread = (struct rt_thread *)parameter;
    RT_ASSERT(thread != RT_NULL);
    RT_ASSERT((thread->stat & RT_THREAD_SUSPEND_MASK) == RT_THREAD_SUSPEND_MASK);
    RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
    level = rt_spin_lock_irqsave(&(thread->spinlock));
    thread->error = -RT_ETIMEOUT;
    rt_list_remove(&(thread->tlist));
    rt_spin_unlock_irqrestore(&(thread->spinlock), level);
    rt_schedule_insert_thread(thread);
    rt_schedule();
}