summaryrefslogtreecommitdiff
path: root/components/drivers
diff options
context:
space:
mode:
authorShell <[email protected]>2024-06-28 00:22:06 +0800
committerGitHub <[email protected]>2024-06-28 00:22:06 +0800
commit3d8c27bcc998c0a43aedc069a4a826e349b85485 (patch)
tree3af25311968339789a42b53974475811b201c8de /components/drivers
parentb79d5013ff4e53e913975db4794b3ea061cbffd9 (diff)
[ktime] quality: remove recursion on hrtimer (#9110)
[ktime] feat: remove recursion on hrtimer Replace recursive algorithm with a loop in hrtimer when determining next timeout event and setup hr timer. Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'components/drivers')
-rw-r--r--components/drivers/ktime/src/hrtimer.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/components/drivers/ktime/src/hrtimer.c b/components/drivers/ktime/src/hrtimer.c
index 8b774676df..728770ad46 100644
--- a/components/drivers/ktime/src/hrtimer.c
+++ b/components/drivers/ktime/src/hrtimer.c
@@ -146,20 +146,26 @@ static void _set_next_timeout_locked(void)
{
rt_ktime_hrtimer_t timer;
rt_ubase_t next_timeout_hrtimer_cnt;
+ rt_bool_t find_next;
- if ((timer = _first_hrtimer()) != RT_NULL)
+ do
{
- next_timeout_hrtimer_cnt = _cnt_convert(timer->timeout_cnt);
- if (next_timeout_hrtimer_cnt > 0)
+ find_next = RT_FALSE;
+ if ((timer = _first_hrtimer()) != RT_NULL)
{
- rt_ktime_hrtimer_settimeout(next_timeout_hrtimer_cnt);
- }
- else
- {
- _hrtimer_process_locked();
- _set_next_timeout_locked();
+ next_timeout_hrtimer_cnt = _cnt_convert(timer->timeout_cnt);
+ if (next_timeout_hrtimer_cnt > 0)
+ {
+ rt_ktime_hrtimer_settimeout(next_timeout_hrtimer_cnt);
+ }
+ else
+ {
+ _hrtimer_process_locked();
+ find_next = RT_TRUE;
+ }
}
}
+ while (find_next);
}
void rt_ktime_hrtimer_process(void)