You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/09/10 15:32:48 UTC
(nuttx) 11/15: sched/sched: Correct the elapsed time calculation.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit b7cd0ab796fe8f3012bde746e51755a8c0cc8bb9
Author: ouyangxiangzhen <ou...@xiaomi.com>
AuthorDate: Tue Aug 27 14:11:13 2024 +0800
sched/sched: Correct the elapsed time calculation.
This patch addresses an issue where the elapsed time was uncorrectly calculated.
Signed-off-by: ouyangxiangzhen <ou...@xiaomi.com>
Signed-off-by: ligd <li...@xiaomi.com>
---
sched/sched/sched_timerexpiration.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/sched/sched/sched_timerexpiration.c b/sched/sched/sched_timerexpiration.c
index a2609ac376..cd5e3d7767 100644
--- a/sched/sched/sched_timerexpiration.c
+++ b/sched/sched/sched_timerexpiration.c
@@ -562,31 +562,20 @@ void nxsched_reassess_timer(void)
clock_t ticks;
clock_t elapsed;
-#ifdef CONFIG_SCHED_TICKLESS_ALARM
- /* Cancel the alarm and get the current time */
+ /* Cancel the timer and get the current time */
+#ifdef CONFIG_SCHED_TICKLESS_ALARM
up_alarm_tick_cancel(&ticks);
-
- /* Convert this to the elapsed time and update clock tickbase */
-
- elapsed = ticks - g_timer_tick;
- g_timer_tick = ticks;
#else
- /* Cancel the timer and get the current time */
-
up_timer_gettick(&ticks);
up_timer_tick_cancel(&elapsed);
DEBUGASSERT(elapsed <= g_timer_interval);
+#endif
- /* Handle the partial timer. This will reassess all timer conditions and
- * re-start the interval timer with the correct delay. Context switches
- * are not permitted in this case because we are not certain of the
- * calling conditions.
- */
+ /* Convert this to the elapsed time and update clock tickbase */
- ticks += g_timer_interval - elapsed;
+ elapsed = ticks - g_timer_tick;
g_timer_tick = ticks;
-#endif
/* Process the timer ticks and start next timer */