diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-04-15 11:26:46 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-05-19 12:00:42 +0200 |
commit | 290309014c15b4eceee9f77c90eb3c81cc223f4b (patch) | |
tree | 4b9ae28399c95783e9ac5847d6a7709f980d62ad /cpukit/rtems | |
parent | score: Optimize _Thread_queue_Compare_priority() (diff) | |
download | rtems-290309014c15b4eceee9f77c90eb3c81cc223f4b.tar.bz2 |
score: Add header to _Watchdog_Remove()
Add watchdog header parameter to _Watchdog_Remove() to be in line with
the other operations. Add _Watchdog_Remove_ticks() and
_Watchdog_Remove_seconds() for convenience.
Update #2307.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/timerimpl.h | 13 | ||||
-rw-r--r-- | cpukit/rtems/src/eventseize.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/eventsurrender.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemoncancel.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemondelete.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/timercancel.c | 3 | ||||
-rw-r--r-- | cpukit/rtems/src/timercreate.c | 23 | ||||
-rw-r--r-- | cpukit/rtems/src/timerdelete.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/timerfireafter.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/timerfirewhen.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/timerreset.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/timerserver.c | 19 | ||||
-rw-r--r-- | cpukit/rtems/src/timerserverfireafter.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/timerserverfirewhen.c | 2 |
14 files changed, 60 insertions, 18 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/timerimpl.h b/cpukit/rtems/include/rtems/rtems/timerimpl.h index b695d5e2fe..4f200efb75 100644 --- a/cpukit/rtems/include/rtems/rtems/timerimpl.h +++ b/cpukit/rtems/include/rtems/rtems/timerimpl.h @@ -50,9 +50,9 @@ extern "C" { typedef struct Timer_server_Control Timer_server_Control; /** - * @brief Method used to schedule the insertion of task based timers. + * @brief Method used for task based timers. */ -typedef void (*Timer_server_Schedule_operation)( +typedef void (*Timer_server_Method)( Timer_server_Control *timer_server, Timer_Control *timer ); @@ -84,9 +84,14 @@ struct Timer_server_Control { Thread_Control *thread; /** + * @brief The cancel method of the timer server. + */ + Timer_server_Method cancel; + + /** * @brief The schedule operation method of the timer server. */ - Timer_server_Schedule_operation schedule_operation; + Timer_server_Method schedule_operation; /** * @brief Interval watchdogs triggered by the timer server. @@ -220,6 +225,8 @@ RTEMS_INLINE_ROUTINE bool _Timer_Is_dormant_class ( return ( the_class == TIMER_DORMANT ); } +void _Timer_Cancel( Timer_Control *the_timer ); + /**@}*/ #ifdef __cplusplus diff --git a/cpukit/rtems/src/eventseize.c b/cpukit/rtems/src/eventseize.c index 929665641c..36b1964820 100644 --- a/cpukit/rtems/src/eventseize.c +++ b/cpukit/rtems/src/eventseize.c @@ -101,7 +101,7 @@ void _Event_Seize( wait_class | THREAD_WAIT_STATE_BLOCKED ); if ( !success ) { - _Watchdog_Remove( &executing->Timer ); + _Watchdog_Remove_ticks( &executing->Timer ); _Thread_Unblock( executing ); } diff --git a/cpukit/rtems/src/eventsurrender.c b/cpukit/rtems/src/eventsurrender.c index ba4e429f1e..e29d203f71 100644 --- a/cpukit/rtems/src/eventsurrender.c +++ b/cpukit/rtems/src/eventsurrender.c @@ -111,7 +111,7 @@ void _Event_Surrender( _Thread_Lock_release_default( the_thread, lock_context ); _Giant_Acquire( cpu_self ); - _Watchdog_Remove( &the_thread->Timer ); + _Watchdog_Remove_ticks( &the_thread->Timer ); _Thread_Unblock( the_thread ); _Giant_Release( cpu_self ); diff --git a/cpukit/rtems/src/ratemoncancel.c b/cpukit/rtems/src/ratemoncancel.c index d4a9102955..67b230fbfc 100644 --- a/cpukit/rtems/src/ratemoncancel.c +++ b/cpukit/rtems/src/ratemoncancel.c @@ -38,7 +38,7 @@ rtems_status_code rtems_rate_monotonic_cancel( _Objects_Put( &the_period->Object ); return RTEMS_NOT_OWNER_OF_RESOURCE; } - (void) _Watchdog_Remove( &the_period->Timer ); + _Watchdog_Remove_ticks( &the_period->Timer ); the_period->state = RATE_MONOTONIC_INACTIVE; _Scheduler_Release_job( the_period->owner, 0 ); _Objects_Put( &the_period->Object ); diff --git a/cpukit/rtems/src/ratemondelete.c b/cpukit/rtems/src/ratemondelete.c index 971ad8ef3d..77cf3fe306 100644 --- a/cpukit/rtems/src/ratemondelete.c +++ b/cpukit/rtems/src/ratemondelete.c @@ -37,7 +37,7 @@ rtems_status_code rtems_rate_monotonic_delete( case OBJECTS_LOCAL: _Scheduler_Release_job( the_period->owner, 0 ); _Objects_Close( &_Rate_monotonic_Information, &the_period->Object ); - (void) _Watchdog_Remove( &the_period->Timer ); + _Watchdog_Remove_ticks( &the_period->Timer ); the_period->state = RATE_MONOTONIC_INACTIVE; _Objects_Put( &the_period->Object ); _Rate_monotonic_Free( the_period ); diff --git a/cpukit/rtems/src/timercancel.c b/cpukit/rtems/src/timercancel.c index a8ce1478da..1e737a25bb 100644 --- a/cpukit/rtems/src/timercancel.c +++ b/cpukit/rtems/src/timercancel.c @@ -45,8 +45,7 @@ rtems_status_code rtems_timer_cancel( switch ( location ) { case OBJECTS_LOCAL: - if ( !_Timer_Is_dormant_class( the_timer->the_class ) ) - (void) _Watchdog_Remove( &the_timer->Ticker ); + _Timer_Cancel( the_timer ); _Objects_Put( &the_timer->Object ); return RTEMS_SUCCESSFUL; diff --git a/cpukit/rtems/src/timercreate.c b/cpukit/rtems/src/timercreate.c index 0b1c44bdc2..2c6d251b8a 100644 --- a/cpukit/rtems/src/timercreate.c +++ b/cpukit/rtems/src/timercreate.c @@ -21,10 +21,33 @@ #include <rtems/system.h> #include <rtems/rtems/status.h> #include <rtems/rtems/support.h> +#include <rtems/score/assert.h> #include <rtems/score/thread.h> #include <rtems/rtems/timerimpl.h> #include <rtems/score/watchdogimpl.h> +void _Timer_Cancel( Timer_Control *the_timer ) +{ + Timer_server_Control *timer_server; + + switch ( the_timer->the_class ) { + case TIMER_INTERVAL: + _Watchdog_Remove_ticks( &the_timer->Ticker ); + break; + case TIMER_TIME_OF_DAY: + _Watchdog_Remove_seconds( &the_timer->Ticker ); + break; + case TIMER_INTERVAL_ON_TASK: + case TIMER_TIME_OF_DAY_ON_TASK: + timer_server = _Timer_server; + (*timer_server->cancel)( timer_server, the_timer ); + break; + default: + _Assert( the_timer->the_class == TIMER_DORMANT ); + break; + } +} + rtems_status_code rtems_timer_create( rtems_name name, rtems_id *id diff --git a/cpukit/rtems/src/timerdelete.c b/cpukit/rtems/src/timerdelete.c index 19232c8096..0849ec5ba6 100644 --- a/cpukit/rtems/src/timerdelete.c +++ b/cpukit/rtems/src/timerdelete.c @@ -38,7 +38,7 @@ rtems_status_code rtems_timer_delete( case OBJECTS_LOCAL: _Objects_Close( &_Timer_Information, &the_timer->Object ); - (void) _Watchdog_Remove( &the_timer->Ticker ); + _Timer_Cancel( the_timer ); _Objects_Put( &the_timer->Object ); _Timer_Free( the_timer ); _Objects_Allocator_unlock(); diff --git a/cpukit/rtems/src/timerfireafter.c b/cpukit/rtems/src/timerfireafter.c index 07862cde8c..84cf46bc37 100644 --- a/cpukit/rtems/src/timerfireafter.c +++ b/cpukit/rtems/src/timerfireafter.c @@ -46,7 +46,7 @@ rtems_status_code rtems_timer_fire_after( switch ( location ) { case OBJECTS_LOCAL: - (void) _Watchdog_Remove( &the_timer->Ticker ); + _Timer_Cancel( the_timer ); _ISR_Disable( level ); diff --git a/cpukit/rtems/src/timerfirewhen.c b/cpukit/rtems/src/timerfirewhen.c index 6ac7d17433..1acbaf9b8f 100644 --- a/cpukit/rtems/src/timerfirewhen.c +++ b/cpukit/rtems/src/timerfirewhen.c @@ -51,7 +51,7 @@ rtems_status_code rtems_timer_fire_when( switch ( location ) { case OBJECTS_LOCAL: - (void) _Watchdog_Remove( &the_timer->Ticker ); + _Timer_Cancel( the_timer ); the_timer->the_class = TIMER_TIME_OF_DAY; _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data ); _Watchdog_Insert_seconds( diff --git a/cpukit/rtems/src/timerreset.c b/cpukit/rtems/src/timerreset.c index 49c4925aa3..7ab172ea4f 100644 --- a/cpukit/rtems/src/timerreset.c +++ b/cpukit/rtems/src/timerreset.c @@ -67,7 +67,7 @@ rtems_status_code rtems_timer_reset( return RTEMS_INCORRECT_STATE; } #endif - _Watchdog_Remove( &the_timer->Ticker ); + (*timer_server->cancel)( timer_server, the_timer ); (*timer_server->schedule_operation)( timer_server, the_timer ); } else { /* diff --git a/cpukit/rtems/src/timerserver.c b/cpukit/rtems/src/timerserver.c index 25191e43d7..15cbdfd59f 100644 --- a/cpukit/rtems/src/timerserver.c +++ b/cpukit/rtems/src/timerserver.c @@ -38,7 +38,7 @@ static void _Timer_server_Stop_interval_system_watchdog( Timer_server_Control *ts ) { - _Watchdog_Remove( &ts->Interval_watchdogs.System_watchdog ); + _Watchdog_Remove_ticks( &ts->Interval_watchdogs.System_watchdog ); } static void _Timer_server_Reset_interval_system_watchdog( @@ -71,7 +71,7 @@ static void _Timer_server_Stop_tod_system_watchdog( Timer_server_Control *ts ) { - _Watchdog_Remove( &ts->TOD_watchdogs.System_watchdog ); + _Watchdog_Remove_seconds( &ts->TOD_watchdogs.System_watchdog ); } static void _Timer_server_Reset_tod_system_watchdog( @@ -210,6 +210,18 @@ static void _Timer_server_Insert_timer_and_make_snapshot( _Thread_Enable_dispatch(); } +static void _Timer_server_Cancel_method( + Timer_server_Control *ts, + Timer_Control *timer +) +{ + if ( timer->the_class == TIMER_INTERVAL_ON_TASK ) { + _Watchdog_Remove( &ts->Interval_watchdogs.Header, &timer->Ticker ); + } else if ( timer->the_class == TIMER_TIME_OF_DAY_ON_TASK ) { + _Watchdog_Remove( &ts->TOD_watchdogs.Header, &timer->Ticker ); + } +} + static void _Timer_server_Schedule_operation_method( Timer_server_Control *ts, Timer_Control *timer @@ -563,9 +575,10 @@ rtems_status_code rtems_timer_initiate_server( ); /* - * Initialize the pointer to the timer schedule method so applications that + * Initialize the pointer to the timer server methods so applications that * do not use the Timer Server do not have to pull it in. */ + ts->cancel = _Timer_server_Cancel_method; ts->schedule_operation = _Timer_server_Schedule_operation_method; ts->Interval_watchdogs.last_snapshot = _Watchdog_Ticks_since_boot; diff --git a/cpukit/rtems/src/timerserverfireafter.c b/cpukit/rtems/src/timerserverfireafter.c index 125664510f..0636782ae0 100644 --- a/cpukit/rtems/src/timerserverfireafter.c +++ b/cpukit/rtems/src/timerserverfireafter.c @@ -50,7 +50,7 @@ rtems_status_code rtems_timer_server_fire_after( switch ( location ) { case OBJECTS_LOCAL: - (void) _Watchdog_Remove( &the_timer->Ticker ); + _Timer_Cancel( the_timer ); _ISR_Disable( level ); diff --git a/cpukit/rtems/src/timerserverfirewhen.c b/cpukit/rtems/src/timerserverfirewhen.c index 32695fb0e6..0069af1c3b 100644 --- a/cpukit/rtems/src/timerserverfirewhen.c +++ b/cpukit/rtems/src/timerserverfirewhen.c @@ -72,7 +72,7 @@ rtems_status_code rtems_timer_server_fire_when( switch ( location ) { case OBJECTS_LOCAL: - (void) _Watchdog_Remove( &the_timer->Ticker ); + _Timer_Cancel( the_timer ); the_timer->the_class = TIMER_TIME_OF_DAY_ON_TASK; _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data ); the_timer->Ticker.initial = seconds - _TOD_Seconds_since_epoch(); |