summaryrefslogtreecommitdiffstats
path: root/cpukit
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
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')
-rw-r--r--cpukit/rtems/include/rtems/rtems/ratemon.h37
-rw-r--r--cpukit/rtems/src/ratemon.c83
2 files changed, 110 insertions, 10 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h b/cpukit/rtems/include/rtems/rtems/ratemon.h
index 85c17cf3eb..cbc0568247 100644
--- a/cpukit/rtems/include/rtems/rtems/ratemon.h
+++ b/cpukit/rtems/include/rtems/rtems/ratemon.h
@@ -46,7 +46,7 @@ typedef enum {
/* was blocking on it */
RATE_MONOTONIC_EXPIRED /* off chain, will be reset by next */
/* rtems_rate_monotonic_period */
-} Rate_Monotonic_Period_states;
+} rtems_rate_monotonic_period_states;
/*
* The following constant is the interval passed to the rate_monontonic_period
@@ -55,16 +55,28 @@ typedef enum {
#define RTEMS_PERIOD_STATUS WATCHDOG_NO_TIMEOUT
+/*
+ * The following defines the period status structure.
+ */
+
+typedef struct {
+ rtems_rate_monotonic_period_states state;
+ unsigned32 ticks_since_last_period;
+ unsigned32 ticks_executed_since_last_period;
+} rtems_rate_monotonic_period_status;
+
/*
* The following structure defines the control block used to manage
* each period.
*/
typedef struct {
- Objects_Control Object;
- Watchdog_Control Timer;
- Rate_Monotonic_Period_states state;
- Thread_Control *owner;
+ Objects_Control Object;
+ Watchdog_Control Timer;
+ rtems_rate_monotonic_period_states state;
+ unsigned32 owner_ticks_executed_at_period;
+ unsigned32 time_at_period;
+ Thread_Control *owner;
} Rate_monotonic_Control;
RTEMS_EXTERN Objects_Information _Rate_monotonic_Information;
@@ -140,6 +152,21 @@ rtems_status_code rtems_rate_monotonic_delete(
);
/*
+ * rtems_rate_monotonic_get_status
+ *
+ * DESCRIPTION:
+ *
+ * This routine implements the rtems_rate_monotonic_get_status directive.
+ * Information about the period indicated by ID is returned.
+ *
+ */
+
+rtems_status_code rtems_rate_monotonic_get_status(
+ Objects_Id id,
+ rtems_rate_monotonic_period_status *status
+);
+
+/*
* rtems_rate_monotonic_period
*
* DESCRIPTION:
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;