2007-05-15 Joel Sherrill <joel.sherrill@oarcorp.com>

* Makefile.am, preinstall.am, libmisc/Makefile.am, rtems/Makefile.am,
	rtems/include/rtems.h, rtems/include/rtems/rtems/ratemon.h,
	rtems/inline/rtems/rtems/ratemon.inl, rtems/src/ratemoncancel.c,
	rtems/src/ratemoncreate.c, rtems/src/ratemondelete.c,
	rtems/src/ratemongetstatus.c, rtems/src/ratemonident.c,
	rtems/src/ratemonperiod.c, rtems/src/ratemontimeout.c,
	score/Makefile.am, score/include/rtems/score/object.h,
	score/src/threadhandler.c, wrapup/Makefile.am: Integrate Rate
	Monotonic Statistics and Period Usage into Rate Monotonic Manager.
	Added the following directives: rtems_rate_monotonic_get_statistics,
	rtems_rate_monotonic_reset_statistics,
	rtems_rate_montonic_reset_all_statistics,
	rtems_rate_montonic_report_statistics, and rtems_object_get_name.
	Obsoleted the rtems/rtmonuse.h file as a public interface.
	* rtems/src/ratemongetstatistics.c,
	rtems/src/ratemonreportstatistics.c, rtems/src/ratemonresetall.c,
	rtems/src/ratemonresetstatistics.c, rtems/src/rtemsobjectgetname.c,
	score/src/objectgetnameasstring.c: New files.
	* libmisc/rtmonuse/rtmonuse.c, libmisc/rtmonuse/rtmonuse.h: Removed.
This commit is contained in:
Joel Sherrill
2007-05-15 20:16:16 +00:00
parent 40082322fa
commit e1bce866cf
27 changed files with 668 additions and 302 deletions

View File

@@ -1,3 +1,25 @@
2007-05-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, preinstall.am, libmisc/Makefile.am, rtems/Makefile.am,
rtems/include/rtems.h, rtems/include/rtems/rtems/ratemon.h,
rtems/inline/rtems/rtems/ratemon.inl, rtems/src/ratemoncancel.c,
rtems/src/ratemoncreate.c, rtems/src/ratemondelete.c,
rtems/src/ratemongetstatus.c, rtems/src/ratemonident.c,
rtems/src/ratemonperiod.c, rtems/src/ratemontimeout.c,
score/Makefile.am, score/include/rtems/score/object.h,
score/src/threadhandler.c, wrapup/Makefile.am: Integrate Rate
Monotonic Statistics and Period Usage into Rate Monotonic Manager.
Added the following directives: rtems_rate_monotonic_get_statistics,
rtems_rate_monotonic_reset_statistics,
rtems_rate_montonic_reset_all_statistics,
rtems_rate_montonic_report_statistics, and rtems_object_get_name.
Obsoleted the rtems/rtmonuse.h file as a public interface.
* rtems/src/ratemongetstatistics.c,
rtems/src/ratemonreportstatistics.c, rtems/src/ratemonresetall.c,
rtems/src/ratemonresetstatistics.c, rtems/src/rtemsobjectgetname.c,
score/src/objectgetnameasstring.c: New files.
* libmisc/rtmonuse/rtmonuse.c, libmisc/rtmonuse/rtmonuse.h: Removed.
2007-05-14 Joel Sherrill <joel.sherrill@OARcorp.com>
* libcsupport/Makefile.am, libcsupport/src/unixlibc.c: Split off dummry

View File

@@ -114,9 +114,6 @@ if LIBSHELL
include_rtems_HEADERS += libmisc/shell/shell.h
endif
## rtmonuse
include_rtems_HEADERS += libmisc/rtmonuse/rtmonuse.h
## i2c
include_rtems_HEADERS += libi2c/libi2c.h

View File

@@ -64,10 +64,6 @@ endif
EXTRA_DIST += shell/README
## rtmonuse
noinst_LIBRARIES += librtmonuse.a
librtmonuse_a_SOURCES = rtmonuse/rtmonuse.c rtmonuse/rtmonuse.h
## serdbg
if LIBSERDBG

View File

@@ -1,225 +0,0 @@
/*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <inttypes.h>
#include <rtems/rtmonuse.h>
typedef struct {
rtems_id id;
uint32_t count;
uint32_t missed_count;
uint32_t min_cpu_time;
uint32_t max_cpu_time;
uint32_t total_cpu_time;
uint32_t min_wall_time;
uint32_t max_wall_time;
uint32_t 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 )
{
uint32_t 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 )
{
uint32_t i;
Period_usage_t *the_usage;
Rate_monotonic_Control *the_period;
uint32_t u32_name;
char *cname;
char name[5];
uint32_t api_index;
uint32_t ival_cpu, fval_cpu;
uint32_t ival_wall, fval_wall;
Objects_Information *information;
if ( !Period_usage_Information ) {
fprintf(stdout, "Period statistics library is not initialized\n" );
return;
}
fprintf(stdout,
"Period information by period\n"
" 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 ];
name[ 0 ] = ' ';
name[ 1 ] = ' ';
name[ 2 ] = ' ';
name[ 3 ] = ' ';
name[ 4 ] = '\0';
if ( the_period->owner ) {
api_index = _Objects_Get_API(the_period->owner->Object.id);
information = _Objects_Information_table[ api_index ][ 1 ];
if ( information->is_string ) {
cname = the_period->owner->Object.name;
name[ 0 ] = cname[0];
name[ 1 ] = cname[1];
name[ 2 ] = cname[2];
name[ 3 ] = cname[3];
name[ 4 ] = '\0';
} else {
u32_name = (uint32_t )the_period->owner->Object.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';
}
}
if ( !isprint(name[0]) ) name[0] = '*';
if ( !isprint(name[1]) ) name[1] = '*';
if ( !isprint(name[2]) ) name[2] = '*';
if ( !isprint(name[3]) ) name[3] = '*';
ival_cpu = the_usage->total_cpu_time * 100 / the_usage->count;
fval_cpu = ival_cpu % 100;
ival_cpu /= 100;
ival_wall = the_usage->total_wall_time * 100 / the_usage->count;
fval_wall = ival_wall % 100;
ival_wall /= 100;
fprintf(stdout,
"0x%08" PRIx32 " %4s %6" PRId32 " %3" PRId32 " "
"%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 " "
"%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 "\n",
the_usage->id,
name,
the_usage->count,
the_usage->missed_count,
the_usage->min_cpu_time,
the_usage->max_cpu_time,
ival_cpu, fval_cpu,
/* (double) the_usage->total_cpu_time / (double) the_usage->count, */
the_usage->min_wall_time,
the_usage->max_wall_time,
ival_wall, fval_wall
/* (double) the_usage->total_wall_time / (double) the_usage->count */
);
}
}

View File

@@ -1,30 +0,0 @@
/**
* @file rtems/rtmonuse.h
*/
/*
* $Id$
*/
#ifndef __RATE_MONOTONIC_USAGE_h
#define __RATE_MONOTONIC_USAGE_h
#ifdef __cplusplus
extern "C" {
#endif
void Period_usage_Initialize( void );
void Period_usage_Reset( void );
void Period_usage_Update(
rtems_id id
);
void Period_usage_Dump( void );
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -206,9 +206,6 @@ $(PROJECT_INCLUDE)/rtems/shell.h: libmisc/shell/shell.h $(PROJECT_INCLUDE)/rtems
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/shell.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/shell.h
endif
$(PROJECT_INCLUDE)/rtems/rtmonuse.h: libmisc/rtmonuse/rtmonuse.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtmonuse.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtmonuse.h
$(PROJECT_INCLUDE)/rtems/libi2c.h: libi2c/libi2c.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/libi2c.h

View File

@@ -52,7 +52,7 @@ include_rtems_rtems_HEADERS += inline/rtems/rtems/asr.inl \
inline/rtems/rtems/timer.inl
## src
librtems_a_SOURCES =
librtems_a_SOURCES = src/rtemsobjectgetname.c
## TASK_C_FILES
librtems_a_SOURCES += src/tasks.c src/taskcreate.c src/taskdelete.c \
@@ -64,7 +64,9 @@ librtems_a_SOURCES += src/tasks.c src/taskcreate.c src/taskdelete.c \
## RATEMON_C_FILES
librtems_a_SOURCES += src/ratemon.c src/ratemoncancel.c src/ratemoncreate.c \
src/ratemondelete.c src/ratemongetstatus.c src/ratemonident.c \
src/ratemondelete.c src/ratemongetstatus.c src/ratemongetstatistics.c \
src/ratemonresetstatistics.c src/ratemonresetall.c \
src/ratemonreportstatistics.c src/ratemonident.c \
src/ratemonperiod.c src/ratemontimeout.c
## INTR_C_FILES

View File

@@ -126,7 +126,7 @@ extern "C" {
* object ID.
*
* Input parameters:
* id - message queue id
* id - object id
*
* Output parameters:
* *name - user defined object name
@@ -139,6 +139,27 @@ rtems_status_code rtems_object_id_to_name(
rtems_name *name
);
/*
* rtems_object_get_name
*
* This directive returns the name associated with the specified
* object ID.
*
* Input parameters:
* id - object id
*
* Output parameters:
* *name - user defined object name
* name - if successful
* NULL - if unsuccessful
*/
char *rtems_object_get_name(
rtems_id id,
size_t length,
char *name
);
#ifdef __cplusplus
}
#endif

View File

@@ -15,7 +15,7 @@
* + conclude current and start the next period
* + obtain status information on a period
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -35,6 +35,9 @@ extern "C" {
#include <rtems/score/object.h>
#include <rtems/score/thread.h>
#include <rtems/score/watchdog.h>
#include <rtems/rtems/status.h>
#include <string.h>
/*
* The following enumerated type defines the states in which a
@@ -58,11 +61,27 @@ typedef enum {
#define RTEMS_PERIOD_STATUS WATCHDOG_NO_TIMEOUT
/*
* The following defines the statistics kept on each period instance.
*/
typedef struct {
uint32_t count;
uint32_t missed_count;
uint32_t min_cpu_time;
uint32_t max_cpu_time;
uint32_t total_cpu_time;
uint32_t min_wall_time;
uint32_t max_wall_time;
uint32_t total_wall_time;
} rtems_rate_monotonic_period_statistics;
/*
* The following defines the period status structure.
*/
typedef struct {
Objects_Id owner;
rtems_rate_monotonic_period_states state;
uint32_t ticks_since_last_period;
uint32_t ticks_executed_since_last_period;
@@ -74,13 +93,14 @@ typedef struct {
*/
typedef struct {
Objects_Control Object;
Watchdog_Control Timer;
rtems_rate_monotonic_period_states state;
uint32_t owner_ticks_executed_at_period;
uint32_t time_at_period;
uint32_t next_length;
Thread_Control *owner;
Objects_Control Object;
Watchdog_Control Timer;
rtems_rate_monotonic_period_states state;
uint32_t owner_ticks_executed_at_period;
uint32_t time_at_period;
uint32_t next_length;
Thread_Control *owner;
rtems_rate_monotonic_period_statistics Statistics;
} Rate_monotonic_Control;
RTEMS_EXTERN Objects_Information _Rate_monotonic_Information;
@@ -170,6 +190,52 @@ rtems_status_code rtems_rate_monotonic_get_status(
rtems_rate_monotonic_period_status *status
);
/*
* rtems_rate_monotonic_get_statistics
*
* DESCRIPTION:
*
* This routine implements the rtems_rate_monotonic_get_statistics directive.
* Statistics gathered from the use of this period are returned.
*/
rtems_status_code rtems_rate_monotonic_get_statistics(
Objects_Id id,
rtems_rate_monotonic_period_statistics *statistics
);
/*
* rtems_rate_monotonic_reset_statistics
*
* DESCRIPTION:
*
* This directive allows a thread to reset the statistics information
* on a specific period instance.
*/
rtems_status_code rtems_rate_monotonic_reset_statistics(
Objects_Id id
);
/*
* rtems_rate_montonic_reset_all_statistics
*
* DESCRIPTION:
*
* This directive allows a thread to reset the statistics information
* on ALL period instances.
*/
void rtems_rate_montonic_reset_all_statistics( void );
/*
* rtems_rate_montonic_report_statistics
*
* DESCRIPTION:
*
* This directive allows a thread to print the statistics information
* on ALL period instances which have non-zero counts using printk.
*/
void rtems_rate_montonic_report_statistics( void );
/*
* rtems_rate_monotonic_period
*
@@ -199,11 +265,28 @@ rtems_status_code rtems_rate_monotonic_period(
* state and not restarted.
*/
void _Rate_monotonic_Timeout (
void _Rate_monotonic_Timeout(
Objects_Id id,
void *ignored
);
/*
* _Rate_monotonic_Reset_statistics
*
* DESCRIPTION:
*
* This method resets the statistics information for a period instance.
*/
#define _Rate_monotonic_Reset_statistics( _the_period ) \
do { \
memset( \
&(_the_period)->Statistics, \
0, \
sizeof( rtems_rate_monotonic_period_statistics ) \
); \
} while (0)
#ifndef __RTEMS_APPLICATION__
#include <rtems/rtems/ratemon.inl>
#endif

View File

@@ -6,7 +6,7 @@
* This file contains the static inline implementation of the inlined
* routines in the Rate Monotonic Manager.
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be

View File

@@ -1,8 +1,7 @@
/*
* Rate Monotonic Manager
* Rate Monotonic Manager -- Cancel a Period
*
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be

View File

@@ -1,8 +1,7 @@
/*
* Rate Monotonic Manager
* Rate Monotonic Manager -- Create a Period
*
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -68,6 +67,8 @@ rtems_status_code rtems_rate_monotonic_create(
_Watchdog_Initialize( &the_period->Timer, NULL, 0, NULL );
_Rate_monotonic_Reset_statistics( the_period );
_Objects_Open(
&_Rate_monotonic_Information,
&the_period->Object,

View File

@@ -1,8 +1,7 @@
/*
* Rate Monotonic Manager
* Rate Monotonic Manager -- Delete a Period
*
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be

View File

@@ -0,0 +1,71 @@
/*
* Rate Monotonic Manager -- Get Statistics
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/rtems/status.h>
#include <rtems/rtems/support.h>
#include <rtems/score/isr.h>
#include <rtems/score/object.h>
#include <rtems/rtems/ratemon.h>
#include <rtems/score/thread.h>
/*PAGE
*
* rtems_rate_monotonic_get_statistics
*
* This directive allows a thread to obtain statistics information on a
* period.
*
* Input parameters:
* id - rate monotonic id
* statistics - pointer to statistics control block
*
* Output parameters:
* RTEMS_SUCCESSFUL - if successful
* error code - if unsuccessful
*
*/
rtems_status_code rtems_rate_monotonic_get_statistics(
Objects_Id id,
rtems_rate_monotonic_period_statistics *statistics
)
{
Objects_Locations location;
Rate_monotonic_Control *the_period;
if ( !statistics )
return RTEMS_INVALID_ADDRESS;
the_period = _Rate_monotonic_Get( id, &location );
switch ( location ) {
case OBJECTS_REMOTE: /* should never return this */
return RTEMS_INTERNAL_ERROR;
case OBJECTS_ERROR:
return RTEMS_INVALID_ID;
case OBJECTS_LOCAL:
*statistics = the_period->Statistics;
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;
}
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}

View File

@@ -1,8 +1,7 @@
/*
* Rate Monotonic Manager
* Rate Monotonic Manager -- Get Status
*
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -61,6 +60,7 @@ rtems_status_code rtems_rate_monotonic_get_status(
return RTEMS_INVALID_ID;
case OBJECTS_LOCAL:
status->owner = ((the_period->owner) ? the_period->owner->Object.id : 0);
status->state = the_period->state;
if ( status->state == RATE_MONOTONIC_INACTIVE ) {

View File

@@ -1,8 +1,7 @@
/*
* Rate Monotonic Manager
* Rate Monotonic Manager -- Name to Id Lookup
*
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be

View File

@@ -1,8 +1,7 @@
/*
* Rate Monotonic Manager
* Rate Monotonic Manager - Period Blocking and Status
*
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -24,6 +23,61 @@
#include <rtems/rtems/ratemon.h>
#include <rtems/score/thread.h>
void _Rate_monotonic_Update_statistics(
Rate_monotonic_Control *the_period
)
{
uint32_t ticks_since_last_period;
uint32_t ticks_executed_since_last_period;
/*
* Assume we are only called in states where it is appropriate
* to update the statistics. This should only be RATE_MONOTONIC_ACTIVE
* and RATE_MONOTONIC_EXPIRED.
*/
/*
* Grab basic information
*/
ticks_since_last_period =
_Watchdog_Ticks_since_boot - the_period->time_at_period;
ticks_executed_since_last_period = the_period->owner->ticks_executed -
the_period->owner_ticks_executed_at_period;
/*
* Now update the statistics
*/
the_period->Statistics.count++;
if ( the_period->state == RATE_MONOTONIC_EXPIRED )
the_period->Statistics.missed_count++;
the_period->Statistics.total_cpu_time += ticks_executed_since_last_period;
the_period->Statistics.total_wall_time += ticks_since_last_period;
/*
* Update CPU time
*/
if ( ticks_executed_since_last_period < the_period->Statistics.min_cpu_time )
the_period->Statistics.min_cpu_time = ticks_executed_since_last_period;
if ( ticks_executed_since_last_period > the_period->Statistics.max_cpu_time )
the_period->Statistics.max_cpu_time = ticks_executed_since_last_period;
/*
* Update Wall time
*/
if ( ticks_since_last_period < the_period->Statistics.min_wall_time )
the_period->Statistics.min_wall_time = ticks_since_last_period;
if ( ticks_since_last_period > the_period->Statistics.max_wall_time )
the_period->Statistics.max_wall_time = ticks_since_last_period;
}
/*PAGE
*
* rtems_rate_monotonic_period
@@ -86,7 +140,12 @@ rtems_status_code rtems_rate_monotonic_period(
_ISR_Disable( level );
switch ( the_period->state ) {
case RATE_MONOTONIC_INACTIVE:
/*
* No need to update statistics -- there are not a period active
*/
_ISR_Enable( level );
the_period->state = RATE_MONOTONIC_ACTIVE;
_Watchdog_Initialize(
&the_period->Timer,
@@ -106,6 +165,12 @@ rtems_status_code rtems_rate_monotonic_period(
return RTEMS_SUCCESSFUL;
case RATE_MONOTONIC_ACTIVE:
/*
* Update statistics from the concluding period
*/
_Rate_monotonic_Update_statistics( the_period );
/*
* This tells the _Rate_monotonic_Timeout that this task is
* in the process of blocking on the period and that we
@@ -143,7 +208,13 @@ rtems_status_code rtems_rate_monotonic_period(
break;
case RATE_MONOTONIC_EXPIRED:
/*
* Update statistics from the concluding period
*/
_Rate_monotonic_Update_statistics( the_period );
_ISR_Enable( level );
the_period->state = RATE_MONOTONIC_ACTIVE;
the_period->owner_ticks_executed_at_period =
_Thread_Executing->ticks_executed;

View File

@@ -0,0 +1,90 @@
/*
* Rate Monotonic Manager -- Report Statistics for All Periods
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems.h>
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
#include <rtems/bspIo.h>
/*
* This directive allows a thread to print the statistics information
* on ALL period instances which have non-zero counts using printk.
*
* The implementation of this directive straddles the fence between
* inside and outside of RTEMS. It is presented as part of the Manager
* but actually uses other services of the Manager.
*/
void rtems_rate_montonic_report_statistics( void )
{
rtems_status_code status;
rtems_id id;
rtems_rate_monotonic_period_statistics the_stats;
rtems_rate_monotonic_period_status the_status;
char name[5];
uint32_t ival_cpu, fval_cpu;
uint32_t ival_wall, fval_wall;
printk(
"Period information by period\n"
" ID OWNER PERIODS MISSED CPU TIME WALL TIME\n"
);
/*
* Cycle through all possible ids and try to report on each one. If it
* is a period that is inactive, we just get an error back. No big deal.
*/
for ( id=_Rate_monotonic_Information.minimum_id ;
id <= _Rate_monotonic_Information.maximum_id ;
id++ ) {
status = rtems_rate_monotonic_get_statistics( id, &the_stats );
if ( status != RTEMS_SUCCESSFUL )
continue;
/* If the above passed, so should this but check it anyway */
status = rtems_rate_monotonic_get_status( id, &the_status );
if ( status != RTEMS_SUCCESSFUL )
continue;
if ( the_stats.count == 0 )
continue;
ival_cpu = the_stats.total_cpu_time * 100 / the_stats.count;
name[ 0 ] = '\0';
if ( the_status.owner ) {
rtems_object_get_name( the_status.owner, sizeof(name), name );
}
fval_cpu = ival_cpu % 100;
ival_cpu /= 100;
ival_wall = the_stats.total_wall_time * 100 / the_stats.count;
fval_wall = ival_wall % 100;
ival_wall /= 100;
printk(
"0x%08" PRIx32 " %4s %6" PRId32 " %3" PRId32 " "
"%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 " "
"%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 "\n",
id, name,
the_stats.count, the_stats.missed_count,
the_stats.min_cpu_time, the_stats.max_cpu_time, ival_cpu, fval_cpu,
the_stats.min_wall_time, the_stats.max_wall_time, ival_wall, fval_wall
);
}
}

View File

@@ -0,0 +1,56 @@
/*
* Rate Monotonic Manager -- Reset Statistics for All Periods
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/rtems/status.h>
#include <rtems/rtems/support.h>
#include <rtems/score/object.h>
#include <rtems/rtems/ratemon.h>
#include <rtems/score/thread.h>
/*
* rtems_rate_montonic_reset_all_statistics
*/
void rtems_rate_montonic_reset_all_statistics( void )
{
Objects_Id id;
rtems_status_code status;
/*
* Prevent allocation or deallocation of any of the periods while
* we are cycling. Also this is an optimization which ensures that
* we only disable/enable once. The call to
* rtems_rate_monotonic_reset_statistics will be in a nested dispatch
* disabled critical section.
*/
_Thread_Disable_dispatch();
/*
* Cycle through all possible ids and try to reset each one. If it
* is a period that is inactive, we just get an error back. No big deal.
*/
for ( id=_Rate_monotonic_Information.minimum_id ;
id <= _Rate_monotonic_Information.maximum_id ;
id++ ) {
status = rtems_rate_monotonic_reset_statistics( id );
}
/*
* Done so exit thread dispatching disabled critical section.
*/
_Thread_Enable_dispatch();
}

View File

@@ -0,0 +1,66 @@
/*
* Rate Monotonic Manager -- Reset Statistics
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/rtems/status.h>
#include <rtems/rtems/support.h>
#include <rtems/score/isr.h>
#include <rtems/score/object.h>
#include <rtems/rtems/ratemon.h>
#include <rtems/score/thread.h>
/*PAGE
*
* rtems_rate_monotonic_reset_statistics
*
* This directive allows a thread to reset the statistics information
* on a specific period instance.
*
* Input parameters:
* id - rate monotonic id
*
* Output parameters:
* RTEMS_SUCCESSFUL - if successful
* error code - if unsuccessful
*
*/
rtems_status_code rtems_rate_monotonic_reset_statistics(
Objects_Id id
)
{
Objects_Locations location;
Rate_monotonic_Control *the_period;
the_period = _Rate_monotonic_Get( id, &location );
switch ( location ) {
case OBJECTS_REMOTE: /* should never return this */
return RTEMS_INTERNAL_ERROR;
case OBJECTS_ERROR:
return RTEMS_INVALID_ID;
case OBJECTS_LOCAL:
_Rate_monotonic_Reset_statistics( the_period );
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;
}
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
}

View File

@@ -1,8 +1,7 @@
/*
* Rate Monotonic Manager
* Rate Monotonic Manager -- Period End Timeout Handler
*
*
* COPYRIGHT (c) 1989-1999.
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be

View File

@@ -0,0 +1,34 @@
/*
* RTEMS Object Helper -- Obtain Name of Object as String
*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/score/object.h>
/*
* This method objects the name of an object and returns its name
* in the form of a C string. It attempts to be careful about
* overflowing the user's string and about returning unprintable characters.
*/
char *rtems_object_get_name(
Objects_Id id,
size_t length,
char *name
)
{
return _Objects_Get_name_as_string( id, length, name );
}

View File

@@ -114,7 +114,7 @@ libscore_a_SOURCES += src/object.c src/objectallocate.c \
src/objectgetisr.c src/objectgetbyindex.c src/objectgetnext.c \
src/objectinitializeinformation.c src/objectnametoid.c \
src/objectshrinkinformation.c src/objectgetnoprotection.c \
src/objectidtoname.c
src/objectidtoname.c src/objectgetnameasstring.c
## PROTECTED_HEAP_C_FILES
libscore_a_SOURCES += src/pheapallocatealigned.c src/pheapallocate.c \

View File

@@ -798,6 +798,24 @@ Objects_Control *_Objects_Get_next(
Objects_Id *next_id_p
);
/**
* This method objects the name of an object and returns its name
* in the form of a C string. It attempts to be careful about
* overflowing the user's string and about returning unprintable characters.
*
* @param[in] id is the object to obtain the name of
* @param[in] length indicates the length of the caller's buffer
* @param[inout] name is a string which will be filled in.
*
* @return This method returns @a name or NULL on error.
*/
char *_Objects_Get_name_as_string(
Objects_Id id,
size_t length,
char *name
);
/*
* Pieces of object.inl are promoted out to the user
*/

View File

@@ -0,0 +1,96 @@
/*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/score/object.h>
#include <rtems/score/thread.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <inttypes.h>
/*
* This method objects the name of an object and returns its name
* in the form of a C string. It attempts to be careful about
* overflowing the user's string and about returning unprintable characters.
*/
char *_Objects_Get_name_as_string(
Objects_Id id,
size_t length,
char *name
)
{
#ifdef RTEMS_POSIX_API
Objects_Information *information;
#endif
char *s;
char *d;
uint32_t i;
char lname[5];
Objects_Control *the_object;
Objects_Locations location;
if ( length == 0 )
return NULL;
if ( name == NULL )
return NULL;
information = _Objects_Get_information( id );
if ( !information )
return NULL;
the_object = _Objects_Get( information, id, &location );
switch ( location ) {
case OBJECTS_REMOTE:
/* not supported */
case OBJECTS_ERROR:
return NULL;
case OBJECTS_LOCAL:
/*
* Neither the Classic nor ITRON APIs use string names.
*/
#ifdef RTEMS_POSIX_API
if ( information->is_string ) {
s = the_object->name;
} else
#endif
{
uint32_t u32_name = (uint32_t) the_object->name;
lname[ 0 ] = (u32_name >> 24) & 0xff;
lname[ 1 ] = (u32_name >> 16) & 0xff;
lname[ 2 ] = (u32_name >> 8) & 0xff;
lname[ 3 ] = (u32_name >> 0) & 0xff;
lname[ 4 ] = '\0';
s = lname;
}
for ( i=0, d=name ; i<(length-1) && *s ; i++, s++, d++ ) {
*d = (!isprint(*s)) ? '*' : *s;
}
*d = '\0';
_Thread_Enable_dispatch();
return name;
}
return NULL; /* unreachable path */
}

View File

@@ -112,7 +112,12 @@ void _Thread_Handler( void )
_Thread_Enable_dispatch();
#if defined(__USE_INIT_FINI__)
if (!doneCons && (volatile void *)_init)
/*
* _init could be a weak symbol and we SHOULD test it but it isn't
* in any configuration I know of and it generates a warning on every
* RTEMS target configuration. --joel (12 May 2007)
*/
if (!doneCons) /* && (volatile void *)_init) */
_init ();
#endif
#if defined(__USE__MAIN__)

View File

@@ -38,7 +38,6 @@ TMP_LIBS += ../libmisc/libmonitor.a
TMP_LIBS += ../libmisc/libuntar.a
TMP_LIBS += ../libmisc/libstackchk.a
TMP_LIBS += ../libmisc/libcpuuse.a
TMP_LIBS += ../libmisc/librtmonuse.a
## XXX temporarily removed because it causes a
## XXX number of BSPs to not link "main(){}" used by autoconf