summaryrefslogtreecommitdiffstats
path: root/c/src/libmisc/rtmonuse
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1997-04-09 20:18:54 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1997-04-09 20:18:54 +0000
commitfc7bc517db4a6b6b5cf0e0e4c829ee01b0cb32a5 (patch)
treead4b85b59d644208f4cf74bc7f04a3d8a7bfc795 /c/src/libmisc/rtmonuse
parentadded rtmonuse and cpuuse directories (diff)
downloadrtems-fc7bc517db4a6b6b5cf0e0e4c829ee01b0cb32a5.tar.bz2
new files.
Diffstat (limited to 'c/src/libmisc/rtmonuse')
-rw-r--r--c/src/libmisc/rtmonuse/Makefile.in53
-rw-r--r--c/src/libmisc/rtmonuse/rtmonuse.c173
-rw-r--r--c/src/libmisc/rtmonuse/rtmonuse.h18
3 files changed, 244 insertions, 0 deletions
diff --git a/c/src/libmisc/rtmonuse/Makefile.in b/c/src/libmisc/rtmonuse/Makefile.in
new file mode 100644
index 0000000000..6f0808f8f2
--- /dev/null
+++ b/c/src/libmisc/rtmonuse/Makefile.in
@@ -0,0 +1,53 @@
+#
+# $Id$
+#
+
+@SET_MAKE@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH=@srcdir@
+
+LIB=${ARCH}/librtmonuse-tmp.a
+
+# C source names, if any, go here -- minus the .c
+C_PIECES=rtmonuse
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+INSTALLED_H_FILES=$(srcdir)/rtmonuse.h
+
+SRCS=$(C_FILES) $(H_FILES) $(INSTALLED_H_FILES)
+OBJS=$(C_O_FILES)
+
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/lib.cfg
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS += -I.
+CFLAGS +=
+
+LD_PATHS +=
+LD_LIBS +=
+LDFLAGS +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+${LIB}: ${SRCS} ${OBJS}
+ $(make-library)
+
+all: ${ARCH} $(SRCS) $(LIB)
+ $(INSTALL) -m 444 ${INSTALLED_H_FILES} ${PROJECT_RELEASE}/include
+# $(INSTALL) -m 444 ${H_FILES} ${PROJECT_RELEASE}/include/rtems
diff --git a/c/src/libmisc/rtmonuse/rtmonuse.c b/c/src/libmisc/rtmonuse/rtmonuse.c
new file mode 100644
index 0000000000..272290176e
--- /dev/null
+++ b/c/src/libmisc/rtmonuse/rtmonuse.c
@@ -0,0 +1,173 @@
+/*
+ * $Id$
+ */
+
+#include <rtems.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+#include "rtmonuse.h"
+
+typedef struct {
+ rtems_id id;
+ unsigned32 count;
+ unsigned32 missed_count;
+ unsigned32 min_cpu_time;
+ unsigned32 max_cpu_time;
+ unsigned32 total_cpu_time;
+ unsigned32 min_wall_time;
+ unsigned32 max_wall_time;
+ unsigned32 total_wall_time;
+} Period_usage_t;
+
+Period_usage_t *Period_usage_Information;
+
+/*PAGE
+ *
+ * Period_usage_Initialize
+ */
+
+void Period_usage_Initialize( void )
+{
+ int maximum;
+
+ maximum = _Configuration_Table->RTEMS_api_configuration->maximum_periods;
+
+ Period_usage_Information = malloc( sizeof(Period_usage_t) * (maximum+1) );
+
+ Period_usage_Reset();
+}
+
+/*PAGE
+ *
+ * Period_usage_Reset
+ */
+
+void Period_usage_Reset( void )
+{
+ unsigned32 i;
+ Period_usage_t *the_usage;
+
+ for ( i=0 ;
+ i<_Configuration_Table->RTEMS_api_configuration->maximum_periods ;
+ i++ ) {
+ the_usage = &Period_usage_Information[ i ];
+
+ the_usage->count = 0;
+ the_usage->missed_count = 0;
+ the_usage->min_cpu_time = 0xFFFFFFFF;
+ the_usage->max_cpu_time = 0;
+ the_usage->total_cpu_time = 0;
+ the_usage->min_wall_time = 0xFFFFFFFF;
+ the_usage->max_wall_time = 0;
+ the_usage->total_wall_time = 0;
+
+ }
+}
+
+/*PAGE
+ *
+ * Period_usage_Update
+ */
+
+void Period_usage_Update(
+ rtems_id id
+)
+{
+ rtems_rate_monotonic_period_status rm_status;
+ rtems_status_code status;
+ Period_usage_t *the_usage;
+
+ assert( Period_usage_Information );
+
+ status = rtems_rate_monotonic_get_status( id, &rm_status );
+ assert( status == RTEMS_SUCCESSFUL );
+
+ the_usage = &Period_usage_Information[ rtems_get_index( id ) ];
+
+ the_usage->id = id;
+ the_usage->count++;
+ if ( rm_status.state == RATE_MONOTONIC_EXPIRED )
+ the_usage->missed_count++;
+ the_usage->total_cpu_time += rm_status.ticks_executed_since_last_period;
+ the_usage->total_wall_time += rm_status.ticks_since_last_period;
+
+ /*
+ * Update CPU time
+ */
+
+ if ( rm_status.ticks_executed_since_last_period < the_usage->min_cpu_time )
+ the_usage->min_cpu_time = rm_status.ticks_executed_since_last_period;
+
+ if ( rm_status.ticks_executed_since_last_period > the_usage->max_cpu_time )
+ the_usage->max_cpu_time = rm_status.ticks_executed_since_last_period;
+
+ /*
+ * Update Wall time
+ */
+
+ if ( rm_status.ticks_since_last_period < the_usage->min_wall_time )
+ the_usage->min_wall_time = rm_status.ticks_since_last_period;
+
+ if ( rm_status.ticks_since_last_period > the_usage->max_wall_time )
+ the_usage->max_wall_time = rm_status.ticks_since_last_period;
+
+}
+
+/*PAGE
+ *
+ * Period_usage_Dump
+ */
+
+void Period_usage_Dump( void )
+{
+ unsigned32 i;
+ Period_usage_t *the_usage;
+ Rate_monotonic_Control *the_period;
+ unsigned32 u32_name;
+ char name[5];
+
+ printf( "Period information by period\n" );
+ printf( " ID OWNER PERIODS MISSED CPU TIME WALL TIME\n" );
+
+ /*
+ * RTEMS does not use an index of zero for object ids.
+ */
+
+ for ( i=1 ;
+ i<_Configuration_Table->RTEMS_api_configuration->maximum_periods ;
+ i++ ) {
+ the_usage = &Period_usage_Information[ i ];
+ if ( the_usage->count == 0 )
+ continue;
+
+ the_period =
+ (Rate_monotonic_Control *)_Rate_monotonic_Information.local_table[ i ];
+
+ if ( the_period->owner )
+ u32_name = *(unsigned32 *)the_period->owner->Object.name;
+ else
+ u32_name = rtems_build_name(' ', ' ', ' ', ' ');
+
+ name[ 0 ] = (u32_name >> 24) & 0xff;
+ name[ 1 ] = (u32_name >> 16) & 0xff;
+ name[ 2 ] = (u32_name >> 8) & 0xff;
+ name[ 3 ] = (u32_name >> 0) & 0xff;
+ name[ 4 ] = '\0';
+
+ printf(
+ "0x%08x %4s %6d %3d %d/%d/%5.2f %d/%d/%3.2f\n",
+ the_usage->id,
+ name,
+ the_usage->count,
+ the_usage->missed_count,
+ the_usage->min_cpu_time,
+ the_usage->max_cpu_time,
+ (double) the_usage->total_cpu_time / (double) the_usage->count,
+ the_usage->min_wall_time,
+ the_usage->max_wall_time,
+ (double) the_usage->total_wall_time / (double) the_usage->count
+ );
+ }
+}
diff --git a/c/src/libmisc/rtmonuse/rtmonuse.h b/c/src/libmisc/rtmonuse/rtmonuse.h
new file mode 100644
index 0000000000..f0580a4f0b
--- /dev/null
+++ b/c/src/libmisc/rtmonuse/rtmonuse.h
@@ -0,0 +1,18 @@
+/*
+ * $Id$
+ */
+
+#ifndef __RATE_MONOTONIC_USAGE_h
+#define __RATE_MONOTONIC_USAGE_h
+
+void Period_usage_Initialize( void );
+
+void Period_usage_Reset( void );
+
+void Period_usage_Update(
+ rtems_id id
+);
+
+void Period_usage_Dump( void );
+
+#endif