forked from Imagelibrary/rtems
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.
This commit is contained in:
@@ -73,7 +73,7 @@ unsigned int alarm(
|
||||
|
||||
_Thread_Disable_dispatch();
|
||||
|
||||
state = _Watchdog_Remove( the_timer );
|
||||
state = _Watchdog_Remove_seconds( the_timer );
|
||||
if ( (state == WATCHDOG_ACTIVE) || (state == WATCHDOG_REMOVE_IT) ) {
|
||||
/*
|
||||
* The stop_time and start_time fields are snapshots of ticks since
|
||||
|
||||
@@ -115,7 +115,7 @@ bool _POSIX_signals_Unblock_thread(
|
||||
* queue, but is also interruptible by a POSIX signal.
|
||||
*/
|
||||
if ( _States_Is_delaying(the_thread->current_state) ) {
|
||||
(void) _Watchdog_Remove( &the_thread->Timer );
|
||||
_Watchdog_Remove_ticks( &the_thread->Timer );
|
||||
_Thread_Unblock( the_thread );
|
||||
} else {
|
||||
_Thread_queue_Extract_with_proxy( the_thread );
|
||||
|
||||
@@ -286,7 +286,7 @@ static void _POSIX_Threads_Terminate_extension(
|
||||
*(void **)the_thread->Wait.return_argument = value_ptr;
|
||||
|
||||
if ( api->schedpolicy == SCHED_SPORADIC )
|
||||
(void) _Watchdog_Remove( &api->Sporadic_timer );
|
||||
_Watchdog_Remove_ticks( &api->Sporadic_timer );
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ int pthread_setschedparam(
|
||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||
|
||||
if ( api->schedpolicy == SCHED_SPORADIC )
|
||||
(void) _Watchdog_Remove( &api->Sporadic_timer );
|
||||
_Watchdog_Remove_ticks( &api->Sporadic_timer );
|
||||
|
||||
api->schedpolicy = policy;
|
||||
api->schedparam = *param;
|
||||
@@ -99,7 +99,7 @@ int pthread_setschedparam(
|
||||
|
||||
case SCHED_SPORADIC:
|
||||
api->ss_high_priority = api->schedparam.sched_priority;
|
||||
_Watchdog_Remove( &api->Sporadic_timer );
|
||||
_Watchdog_Remove_ticks( &api->Sporadic_timer );
|
||||
_POSIX_Threads_Sporadic_budget_TSR( 0, the_thread );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ int timer_delete(
|
||||
case OBJECTS_LOCAL:
|
||||
_Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
|
||||
ptimer->state = POSIX_TIMER_STATE_FREE;
|
||||
(void) _Watchdog_Remove( &ptimer->Timer );
|
||||
_Watchdog_Remove_ticks( &ptimer->Timer );
|
||||
_Objects_Put( &ptimer->Object );
|
||||
_POSIX_Timer_Free( ptimer );
|
||||
_Objects_Allocator_unlock();
|
||||
|
||||
@@ -39,7 +39,7 @@ bool _POSIX_Timer_Insert_helper(
|
||||
{
|
||||
ISR_Level level;
|
||||
|
||||
(void) _Watchdog_Remove( timer );
|
||||
_Watchdog_Remove_ticks( timer );
|
||||
_ISR_Disable( level );
|
||||
|
||||
/*
|
||||
|
||||
@@ -85,7 +85,7 @@ int timer_settime(
|
||||
/* First, it verifies if the timer must be stopped */
|
||||
if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
|
||||
/* Stop the timer */
|
||||
(void) _Watchdog_Remove( &ptimer->Timer );
|
||||
_Watchdog_Remove_ticks( &ptimer->Timer );
|
||||
/* The old data of the timer are returned */
|
||||
if ( ovalue )
|
||||
*ovalue = ptimer->timer_data;
|
||||
|
||||
@@ -72,7 +72,7 @@ useconds_t ualarm(
|
||||
|
||||
_Thread_Disable_dispatch();
|
||||
|
||||
state = _Watchdog_Remove( the_timer );
|
||||
state = _Watchdog_Remove_ticks( the_timer );
|
||||
if ( (state == WATCHDOG_ACTIVE) || (state == WATCHDOG_REMOVE_IT) ) {
|
||||
/*
|
||||
* The stop_time and start_time fields are snapshots of ticks since
|
||||
|
||||
@@ -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
|
||||
);
|
||||
@@ -83,10 +83,15 @@ 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
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 {
|
||||
/*
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -216,7 +216,7 @@ RTEMS_INLINE_ROUTINE MRSP_Status _MRSP_Wait_for_ownership(
|
||||
_Thread_Set_life_protection( initial_life_protection );
|
||||
|
||||
if ( timeout > 0 ) {
|
||||
_Watchdog_Remove( &executing->Timer );
|
||||
_Watchdog_Remove_ticks( &executing->Timer );
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -99,10 +99,12 @@ void _Watchdog_Handler_initialization( void );
|
||||
* This routine removes @a the_watchdog from the watchdog chain on which
|
||||
* it resides and returns the state @a the_watchdog timer was in.
|
||||
*
|
||||
* @param[in] header The watchdog chain.
|
||||
* @param[in] the_watchdog will be removed
|
||||
* @retval the state in which @a the_watchdog was in when removed
|
||||
*/
|
||||
Watchdog_States _Watchdog_Remove (
|
||||
Watchdog_Header *header,
|
||||
Watchdog_Control *the_watchdog
|
||||
);
|
||||
|
||||
@@ -306,6 +308,20 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Insert_seconds(
|
||||
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE Watchdog_States _Watchdog_Remove_ticks(
|
||||
Watchdog_Control *the_watchdog
|
||||
)
|
||||
{
|
||||
return _Watchdog_Remove( &_Watchdog_Ticks_header, the_watchdog );
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE Watchdog_States _Watchdog_Remove_seconds(
|
||||
Watchdog_Control *the_watchdog
|
||||
)
|
||||
{
|
||||
return _Watchdog_Remove( &_Watchdog_Seconds_header, the_watchdog );
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine resets THE_WATCHDOG timer to its state at INSERT
|
||||
* time. This routine is valid only on interval watchdog timers
|
||||
@@ -318,7 +334,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Reset_ticks(
|
||||
)
|
||||
{
|
||||
|
||||
(void) _Watchdog_Remove( the_watchdog );
|
||||
_Watchdog_Remove_ticks( the_watchdog );
|
||||
|
||||
_Watchdog_Insert( &_Watchdog_Ticks_header, the_watchdog );
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ static void _Thread_blocking_operation_Finalize(
|
||||
if ( _Watchdog_Is_active( &the_thread->Timer ) ) {
|
||||
_Watchdog_Deactivate( &the_thread->Timer );
|
||||
_Thread_queue_Release( lock_context );
|
||||
(void) _Watchdog_Remove( &the_thread->Timer );
|
||||
_Watchdog_Remove_ticks( &the_thread->Timer );
|
||||
} else
|
||||
_Thread_queue_Release( lock_context );
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ static void _Thread_Make_zombie( Thread_Control *the_thread )
|
||||
|
||||
_Thread_Set_state( the_thread, STATES_ZOMBIE );
|
||||
_Thread_queue_Extract_with_proxy( the_thread );
|
||||
_Watchdog_Remove( &the_thread->Timer );
|
||||
_Watchdog_Remove_ticks( &the_thread->Timer );
|
||||
|
||||
_ISR_lock_ISR_disable_and_acquire( &zombies->Lock, &lock_context );
|
||||
_Chain_Append_unprotected( &zombies->Chain, &the_thread->Object.Node );
|
||||
@@ -235,7 +235,7 @@ static void _Thread_Start_life_change(
|
||||
|
||||
_Thread_Set_state( the_thread, STATES_RESTARTING );
|
||||
_Thread_queue_Extract_with_proxy( the_thread );
|
||||
_Watchdog_Remove( &the_thread->Timer );
|
||||
_Watchdog_Remove_ticks( &the_thread->Timer );
|
||||
_Scheduler_Set_priority_if_higher( scheduler, the_thread, priority );
|
||||
_Thread_Add_post_switch_action( the_thread, &the_thread->Life.Action );
|
||||
_Thread_Ready( the_thread );
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <rtems/score/watchdogimpl.h>
|
||||
|
||||
Watchdog_States _Watchdog_Remove(
|
||||
Watchdog_Header *header,
|
||||
Watchdog_Control *the_watchdog
|
||||
)
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ void _Watchdog_Tickle(
|
||||
}
|
||||
|
||||
do {
|
||||
watchdog_state = _Watchdog_Remove( the_watchdog );
|
||||
watchdog_state = _Watchdog_Remove( header, the_watchdog );
|
||||
|
||||
_ISR_Enable( level );
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ static rtems_timer_service_routine test_release_from_isr(
|
||||
watchdog->delta_interval == 0
|
||||
&& watchdog->routine == _Rate_monotonic_Timeout
|
||||
) {
|
||||
Watchdog_States state = _Watchdog_Remove( watchdog );
|
||||
Watchdog_States state = _Watchdog_Remove_ticks( watchdog );
|
||||
|
||||
rtems_test_assert( state == WATCHDOG_ACTIVE );
|
||||
(*watchdog->routine)( watchdog->id, watchdog->user_data );
|
||||
|
||||
@@ -52,7 +52,7 @@ static rtems_timer_service_routine test_release_from_isr(
|
||||
watchdog->delta_interval == 0
|
||||
&& watchdog->routine == _Thread_queue_Timeout
|
||||
) {
|
||||
Watchdog_States state = _Watchdog_Remove( watchdog );
|
||||
Watchdog_States state = _Watchdog_Remove_ticks( watchdog );
|
||||
|
||||
rtems_test_assert( state == WATCHDOG_ACTIVE );
|
||||
(*watchdog->routine)( watchdog->id, watchdog->user_data );
|
||||
|
||||
Reference in New Issue
Block a user