Skip to content

Commit b7cd0ab

Browse files
Fix-Pointxiaoxiang781216
authored andcommitted
sched/sched: Correct the elapsed time calculation.
This patch addresses an issue where the elapsed time was uncorrectly calculated. Signed-off-by: ouyangxiangzhen <[email protected]> Signed-off-by: ligd <[email protected]>
1 parent bc1e1e1 commit b7cd0ab

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

sched/sched/sched_timerexpiration.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -562,31 +562,20 @@ void nxsched_reassess_timer(void)
562562
clock_t ticks;
563563
clock_t elapsed;
564564

565-
#ifdef CONFIG_SCHED_TICKLESS_ALARM
566-
/* Cancel the alarm and get the current time */
565+
/* Cancel the timer and get the current time */
567566

567+
#ifdef CONFIG_SCHED_TICKLESS_ALARM
568568
up_alarm_tick_cancel(&ticks);
569-
570-
/* Convert this to the elapsed time and update clock tickbase */
571-
572-
elapsed = ticks - g_timer_tick;
573-
g_timer_tick = ticks;
574569
#else
575-
/* Cancel the timer and get the current time */
576-
577570
up_timer_gettick(&ticks);
578571
up_timer_tick_cancel(&elapsed);
579572
DEBUGASSERT(elapsed <= g_timer_interval);
573+
#endif
580574

581-
/* Handle the partial timer. This will reassess all timer conditions and
582-
* re-start the interval timer with the correct delay. Context switches
583-
* are not permitted in this case because we are not certain of the
584-
* calling conditions.
585-
*/
575+
/* Convert this to the elapsed time and update clock tickbase */
586576

587-
ticks += g_timer_interval - elapsed;
577+
elapsed = ticks - g_timer_tick;
588578
g_timer_tick = ticks;
589-
#endif
590579

591580
/* Process the timer ticks and start next timer */
592581

0 commit comments

Comments
 (0)