个人理解:多核都有独立的定时器中断和tick计数,用于判断在当前核上的线程时间片是否用完。但是系统TICK是唯一的,既系统暴露给延时函数等的TICK值是唯一的,即核0上的tick计数值。可以从rt_tick_increase和rt_tick的定义理解一下。
/* src/clock.c */
/**
* This function will notify kernel there is one tick passed. Normally,
* this function is invoked by clock ISR.
*/
void rt_tick_increase(void)
{
struct rt_thread *thread;
/* increase the global tick */
#ifdef RT_USING_SMP
rt_cpu_self()->tick ++;
#else
++ rt_tick;
#endif
/* check time slice */
thread = rt_thread_self();
-- thread->remaining_tick;
if (thread->remaining_tick == 0)
{
/* change to initialized tick */
thread->remaining_tick = thread->init_tick;
thread->stat |= RT_THREAD_STAT_YIELD;
/* yield */
rt_thread_yield();
}
/* check timer */
rt_timer_check();
}
/* src/clock.c */
#ifdef RT_USING_SMP
#define rt_tick rt_cpu_index(0)->tick
#else
static rt_tick_t rt_tick = 0;
#endif