From 113ef9fc7e8e2bfbb16a5abccd995dead249d482 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 9 Apr 1997 20:02:29 +0000 Subject: added support for statistics on rate monotonic periods. --- cpukit/rtems/src/ratemon.c | 83 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-) (limited to 'cpukit/rtems/src/ratemon.c') diff --git a/cpukit/rtems/src/ratemon.c b/cpukit/rtems/src/ratemon.c index d3524b02d6..959ef7dcb8 100644 --- a/cpukit/rtems/src/ratemon.c +++ b/cpukit/rtems/src/ratemon.c @@ -213,6 +213,60 @@ rtems_status_code rtems_rate_monotonic_delete( return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ } +/*PAGE + * + * rtems_rate_monotonic_get_status + * + * This directive allows a thread to obtain status information on a + * period. + * + * Input parameters: + * id - rate monotonic id + * status - pointer to status control block + * + * Output parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + * + */ + +rtems_status_code rtems_rate_monotonic_get_status( + Objects_Id id, + rtems_rate_monotonic_period_status *status +) +{ + Objects_Locations location; + Rate_monotonic_Control *the_period; + + the_period = _Rate_monotonic_Get( id, &location ); + switch ( location ) { + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + case OBJECTS_REMOTE: /* should never return this */ + return RTEMS_INTERNAL_ERROR; + case OBJECTS_LOCAL: + status->state = the_period->state; + + if ( status->state == RATE_MONOTONIC_INACTIVE ) { + status->ticks_since_last_period = 0; + status->ticks_executed_since_last_period = 0; + } else { + status->ticks_since_last_period = + _Watchdog_Ticks_since_boot - the_period->time_at_period; + + status->ticks_executed_since_last_period = + the_period->owner->ticks_executed - + the_period->owner_ticks_executed_at_period; + } + + _Thread_Enable_dispatch(); + return RTEMS_SUCCESSFUL; + } + + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} + + /*PAGE * * rtems_rate_monotonic_period @@ -233,11 +287,11 @@ rtems_status_code rtems_rate_monotonic_period( rtems_interval length ) { - Rate_monotonic_Control *the_period; - Objects_Locations location; - rtems_status_code return_value; - Rate_Monotonic_Period_states local_state; - ISR_Level level; + Rate_monotonic_Control *the_period; + Objects_Locations location; + rtems_status_code return_value; + rtems_rate_monotonic_period_states local_state; + ISR_Level level; the_period = _Rate_monotonic_Get( id, &location ); switch ( location ) { @@ -281,6 +335,12 @@ rtems_status_code rtems_rate_monotonic_period( id, NULL ); + + the_period->owner_ticks_executed_at_period = + _Thread_Executing->ticks_executed; + + the_period->time_at_period = _Watchdog_Ticks_since_boot; + _Watchdog_Insert_ticks( &the_period->Timer, length ); _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; @@ -322,6 +382,10 @@ rtems_status_code rtems_rate_monotonic_period( case RATE_MONOTONIC_EXPIRED: _ISR_Enable( level ); the_period->state = RATE_MONOTONIC_ACTIVE; + the_period->owner_ticks_executed_at_period = + _Thread_Executing->ticks_executed; + the_period->time_at_period = _Watchdog_Ticks_since_boot; + _Watchdog_Insert_ticks( &the_period->Timer, length ); _Thread_Enable_dispatch(); return RTEMS_TIMEOUT; @@ -372,9 +436,18 @@ void _Rate_monotonic_Timeout( if ( _States_Is_waiting_for_period( the_thread->current_state ) && the_thread->Wait.id == the_period->Object.id ) { _Thread_Unblock( the_thread ); + the_period->owner_ticks_executed_at_period = + the_thread->ticks_executed; + + the_period->time_at_period = _Watchdog_Ticks_since_boot; + _Watchdog_Reset( &the_period->Timer ); } else if ( the_period->state == RATE_MONOTONIC_OWNER_IS_BLOCKING ) { the_period->state = RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING; + the_period->owner_ticks_executed_at_period = + the_thread->ticks_executed; + + the_period->time_at_period = _Watchdog_Ticks_since_boot; _Watchdog_Reset( &the_period->Timer ); } else the_period->state = RATE_MONOTONIC_EXPIRED; -- cgit v1.2.3