Skip to content

Commit 823edfd

Browse files
committed
修复溢出,删除冗余
1 parent 735b65a commit 823edfd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/timer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* 2023-09-15 xqyjlj perf rt_hw_interrupt_disable/enable
2323
* 2024-01-25 Shell add RT_TIMER_FLAG_THREAD_TIMER for timer to sync with sched
2424
* 2024-05-01 wdfk-prog The rt_timer_check and _soft_timer_check functions are merged
25+
* 2025-06-01 htl5241 remove redundancy
26+
* fix timer overflow
2527
*/
2628

2729
#include <rtthread.h>
@@ -494,8 +496,6 @@ static void _timer_check(rt_list_t *timer_list, struct rt_spinlock *lock)
494496

495497
level = rt_spin_lock_irqsave(lock);
496498

497-
current_tick = rt_tick_get();
498-
499499
rt_list_init(&list);
500500

501501
while (!rt_list_isempty(&timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
@@ -762,7 +762,7 @@ void rt_timer_check(void)
762762
rt_tick_t next_timeout;
763763

764764
ret = _timer_list_next_timeout(_soft_timer_list, &next_timeout);
765-
if ((ret == RT_EOK) && (next_timeout <= rt_tick_get()))
765+
if ((ret == RT_EOK) && ((rt_tick_get() - next_timeout) < RT_TICK_MAX / 2))
766766
{
767767
rt_sem_release(&_soft_timer_sem);
768768
}

0 commit comments

Comments
 (0)