/* system timer thread entry */ static void rt_thread_timer_entry(void *parameter) { while (1) { /* take software timer semaphore */ rt_sem_take(&timer_sem, RT_WAITING_FOREVER); /* lock scheduler */ rt_enter_critical(); /* check software timer */ rt_soft_timer_check(); /* unlock scheduler */ rt_exit_critical(); } }
/* system timer thread entry */ static void rt_thread_timer_entry(void *parameter) { rt_tick_t next_timeout; while (1) { /* get the next timeout tick */ next_timeout = rt_timer_list_next_timeout(rt_soft_timer_list); if (next_timeout == RT_TICK_MAX) { /* no software timer exist, suspend self. */ rt_thread_suspend(rt_thread_self()); rt_schedule(); } else { rt_tick_t current_tick; /* get current tick */ current_tick = rt_tick_get(); if ((next_timeout - current_tick) < RT_TICK_MAX/2) { /* get the delta timeout tick */ next_timeout = next_timeout - current_tick; rt_thread_delay_hmsm(next_timeout); } } /* lock scheduler */ rt_enter_critical(); /* check software timer */ rt_soft_timer_check(); /* unlock scheduler */ rt_exit_critical(); } }