summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/ratemon.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1997-04-09 20:02:29 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1997-04-09 20:02:29 +0000
commit113ef9fc7e8e2bfbb16a5abccd995dead249d482 (patch)
tree8246df9906e4681307e43c74fed1f9875e5a1af8 /cpukit/rtems/src/ratemon.c
parentRate monotonic period and cpu usage monitor libraries and tests added. (diff)
downloadrtems-113ef9fc7e8e2bfbb16a5abccd995dead249d482.tar.bz2
added support for statistics on rate monotonic periods.
Diffstat (limited to 'cpukit/rtems/src/ratemon.c')
-rw-r--r--cpukit/rtems/src/ratemon.c83
1 files changed, 78 insertions, 5 deletions
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
@@ -215,6 +215,60 @@ rtems_status_code rtems_rate_monotonic_delete(
/*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
*
* This directive allows a thread to manipulate a rate monotonic timer.
@@ -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;