Skip to content

Commit

Permalink
[timer][core]定时器回调临时保持后在触发回调
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqingli05 committed Jan 13, 2024
1 parent 8da86e7 commit d7e805e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,8 @@ void rt_timer_check(void)
rt_tick_t current_tick;
rt_base_t level;
rt_list_t list;
void (*temp_func)(void *parameter);
void *temp_parameter;

RT_ASSERT(rt_interrupt_get_nest() > 0);

Expand Down Expand Up @@ -696,9 +698,11 @@ void rt_timer_check(void)
}
/* add timer to temporary list */
rt_list_insert_after(&list, &(t->row[RT_TIMER_SKIP_LIST_LEVEL - 1]));
temp_func = t->timeout_func;
temp_parameter = t->parameter;
rt_spin_unlock_irqrestore(&_hard_spinlock, level);
/* call timeout function */
t->timeout_func(t->parameter);
temp_func(temp_parameter);

/* re-get tick */
current_tick = rt_tick_get();
Expand Down Expand Up @@ -754,6 +758,8 @@ void rt_soft_timer_check(void)
struct rt_timer *t;
rt_base_t level;
rt_list_t list;
void (*temp_func)(void *parameter);
void *temp_parameter;

rt_list_init(&list);
LOG_D("software timer check enter");
Expand Down Expand Up @@ -782,13 +788,13 @@ void rt_soft_timer_check(void)
}
/* add timer to temporary list */
rt_list_insert_after(&list, &(t->row[RT_TIMER_SKIP_LIST_LEVEL - 1]));

_soft_timer_status = RT_SOFT_TIMER_BUSY;

temp_func = t->timeout_func;
temp_parameter = t->parameter;
rt_spin_unlock_irqrestore(&_soft_spinlock, level);

/* call timeout function */
t->timeout_func(t->parameter);
temp_func(temp_parameter);

RT_OBJECT_HOOK_CALL(rt_timer_exit_hook, (t));
LOG_D("current tick: %d", current_tick);
Expand Down

0 comments on commit d7e805e

Please sign in to comment.