Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[timer][core]定时器回调临时保持后在触发回调 #8489

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[timer][core]定时器回调临时保持后在触发回调
  • Loading branch information
yuqingli05 committed Jan 13, 2024
commit d7e805e30efe319ab79c148d33fd9570c8290510
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
Loading