@@ -93,14 +93,12 @@ static clock_t nxsched_timer_start(clock_t ticks, clock_t interval);
93
93
94
94
static clock_t g_timer_tick ;
95
95
96
- #ifndef CONFIG_SCHED_TICKLESS_ALARM
97
96
/* This is the duration of the currently active timer or, when
98
97
* nxsched_timer_expiration() is called, the duration of interval timer
99
98
* that just expired. The value zero means that no timer was active.
100
99
*/
101
100
102
101
static unsigned int g_timer_interval ;
103
- #endif
104
102
105
103
/****************************************************************************
106
104
* Private Functions
@@ -464,7 +462,7 @@ void nxsched_alarm_tick_expiration(clock_t ticks)
464
462
nexttime = nxsched_timer_process (ticks , elapsed , false);
465
463
466
464
flags = enter_critical_section ();
467
- nxsched_timer_start (ticks , nexttime );
465
+ g_timer_interval = nxsched_timer_start (ticks , nexttime );
468
466
leave_critical_section (flags );
469
467
}
470
468
@@ -593,11 +591,33 @@ void nxsched_reassess_timer(void)
593
591
/* Process the timer ticks and start next timer */
594
592
595
593
nexttime = nxsched_timer_process (ticks , elapsed , true);
596
- elapsed = nxsched_timer_start (ticks , nexttime );
594
+ g_timer_interval = nxsched_timer_start (ticks , nexttime );
595
+ }
597
596
598
- #ifndef CONFIG_SCHED_TICKLESS_ALARM
599
- g_timer_interval = elapsed ;
600
- #endif
597
+ /****************************************************************************
598
+ * Name: nxsched_get_next_expired
599
+ *
600
+ * Description:
601
+ * Get the time remaining until the next timer expiration.
602
+ *
603
+ * Input Parameters:
604
+ * None
605
+ *
606
+ * Returned Value:
607
+ * The time remaining until the next timer expiration.
608
+ *
609
+ ****************************************************************************/
610
+
611
+ clock_t nxsched_get_next_expired (void )
612
+ {
613
+ irqstate_t flags ;
614
+ sclock_t ret ;
615
+
616
+ flags = enter_critical_section ();
617
+ ret = g_timer_tick + g_timer_interval - clock_systime_ticks ();
618
+ leave_critical_section (flags );
619
+
620
+ return ret < 0 ? 0 : ret ;
601
621
}
602
622
603
623
#endif /* CONFIG_SCHED_TICKLESS */
0 commit comments