/* This function will let current thread yield processor, and scheduler will choose the highest thread to run. After yield processor, the current thread is still in READY state.  */
rt_err_t rt_thread_yield(void)
/* This function will let current thread yield processor, and scheduler will choose the highest thread to run. After yield processor, the current thread is still in READY state.  */
rt_err_t rt_thread_yield(void)
{
    struct rt_thread *thread;
    rt_base_t level;
    thread = rt_thread_self();
    level = rt_spin_lock_irqsave(&(thread->spinlock));
    rt_atomic_store(&thread->remaining_tick, thread->init_tick);
    thread->stat |= RT_THREAD_STAT_YIELD;
    rt_spin_unlock_irqrestore(&(thread->spinlock), level);
    rt_schedule();
    return RT_EOK;
}