summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/timerfireafter.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/rtems/src/timerfireafter.c')
-rw-r--r--cpukit/rtems/src/timerfireafter.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/cpukit/rtems/src/timerfireafter.c b/cpukit/rtems/src/timerfireafter.c
index cead1426a4..98b5d36e91 100644
--- a/cpukit/rtems/src/timerfireafter.c
+++ b/cpukit/rtems/src/timerfireafter.c
@@ -51,6 +51,7 @@ rtems_status_code rtems_timer_fire_after(
{
Timer_Control *the_timer;
Objects_Locations location;
+ ISR_Level level;
if ( ticks == 0 )
return RTEMS_INVALID_NUMBER;
@@ -68,8 +69,29 @@ rtems_status_code rtems_timer_fire_after(
case OBJECTS_LOCAL:
(void) _Watchdog_Remove( &the_timer->Ticker );
- the_timer->the_class = TIMER_INTERVAL;
- _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
+
+ _ISR_Disable( level );
+
+ /*
+ * Check to see if the watchdog has just been inserted by a
+ * higher priority interrupt. If so, abandon this insert.
+ */
+
+ if ( the_timer->Ticker.state != WATCHDOG_INACTIVE ) {
+ _ISR_Enable( level );
+ return RTEMS_SUCCESSFUL;
+ }
+
+ /*
+ * OK. Now we now the timer was not rescheduled by an interrupt
+ * so we can atomically initialize it as in use.
+ */
+
+ the_timer->the_class = TIMER_INTERVAL;
+ _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
+ _ISR_Enable( level );
+
+
_Watchdog_Insert_ticks( &the_timer->Ticker, ticks );
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;