forked from Imagelibrary/rtems
2007-05-21 Joel Sherrill <joel.sherrill@oarcorp.com>
* rtems/src/ratemonperiod.c: Fix math ordering bug which resulted in a negative value in some circumstances. Also cleaned up to share uptime declaration.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2007-05-21 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
|
* rtems/src/ratemonperiod.c: Fix math ordering bug which resulted in a
|
||||||
|
negative value in some circumstances. Also cleaned up to share uptime
|
||||||
|
declaration.
|
||||||
|
|
||||||
2007-05-17 Joel Sherrill <joel.sherrill@oarcorp.com>
|
2007-05-17 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
* ChangeLog, configure.ac, libcsupport/src/__times.c,
|
* ChangeLog, configure.ac, libcsupport/src/__times.c,
|
||||||
|
|||||||
@@ -76,20 +76,23 @@ void _Rate_monotonic_Update_statistics(
|
|||||||
|
|
||||||
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
|
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
|
||||||
{
|
{
|
||||||
struct timespec ran;
|
struct timespec ran, used;
|
||||||
|
|
||||||
/* executed = current cpu usage - value at start of period */
|
/* Grab CPU usage when the thread got switched in */
|
||||||
_Timespec_Subtract(
|
used = _Thread_Executing->cpu_time_used;
|
||||||
&the_period->owner_executed_at_period,
|
|
||||||
&_Thread_Executing->cpu_time_used,
|
|
||||||
&executed
|
|
||||||
);
|
|
||||||
|
|
||||||
/* How much time time since last context switch */
|
/* How much time time since last context switch */
|
||||||
_Timespec_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
|
_Timespec_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
|
||||||
|
|
||||||
/* executed += ran */
|
/* executed += ran */
|
||||||
_Timespec_Add_to( &executed, &ran );
|
_Timespec_Add_to( &used, &ran );
|
||||||
|
|
||||||
|
/* executed = current cpu usage - value at start of period */
|
||||||
|
_Timespec_Subtract(
|
||||||
|
&the_period->owner_executed_at_period,
|
||||||
|
&used,
|
||||||
|
&executed
|
||||||
|
);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ticks_executed_since_last_period = the_period->owner->ticks_executed -
|
ticks_executed_since_last_period = the_period->owner->ticks_executed -
|
||||||
@@ -103,6 +106,7 @@ void _Rate_monotonic_Update_statistics(
|
|||||||
stats = &the_period->Statistics;
|
stats = &the_period->Statistics;
|
||||||
stats->count++;
|
stats->count++;
|
||||||
|
|
||||||
|
|
||||||
if ( the_period->state == RATE_MONOTONIC_EXPIRED )
|
if ( the_period->state == RATE_MONOTONIC_EXPIRED )
|
||||||
stats->missed_count++;
|
stats->missed_count++;
|
||||||
|
|
||||||
@@ -214,29 +218,38 @@ rtems_status_code rtems_rate_monotonic_period(
|
|||||||
|
|
||||||
_ISR_Disable( level );
|
_ISR_Disable( level );
|
||||||
switch ( the_period->state ) {
|
switch ( the_period->state ) {
|
||||||
case RATE_MONOTONIC_INACTIVE:
|
case RATE_MONOTONIC_INACTIVE: {
|
||||||
|
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
|
||||||
|
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
|
||||||
|
struct timespec uptime;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No need to update statistics -- there are not a period active
|
* No need to update statistics -- there are not a period active
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
|
||||||
|
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
|
||||||
|
_TOD_Get_uptime( &uptime );
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
|
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
|
||||||
/*
|
/*
|
||||||
* Since the statistics didn't update the starting time,
|
* Since the statistics didn't update the starting time,
|
||||||
* we do it here.
|
* we do it here.
|
||||||
*/
|
*/
|
||||||
_TOD_Get_uptime( &the_period->time_at_period );
|
the_period->time_at_period = uptime;
|
||||||
#else
|
#else
|
||||||
the_period->time_at_period = _Watchdog_Ticks_since_boot;
|
the_period->time_at_period = _Watchdog_Ticks_since_boot;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
|
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
|
||||||
{
|
{
|
||||||
struct timespec ran, uptime;
|
struct timespec ran;
|
||||||
|
|
||||||
_TOD_Get_uptime( &uptime );
|
|
||||||
|
|
||||||
the_period->owner_executed_at_period =
|
the_period->owner_executed_at_period =
|
||||||
_Thread_Executing->cpu_time_used;
|
_Thread_Executing->cpu_time_used;
|
||||||
|
|
||||||
@@ -268,7 +281,7 @@ rtems_status_code rtems_rate_monotonic_period(
|
|||||||
_Watchdog_Insert_ticks( &the_period->Timer, length );
|
_Watchdog_Insert_ticks( &the_period->Timer, length );
|
||||||
_Thread_Enable_dispatch();
|
_Thread_Enable_dispatch();
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
|
}
|
||||||
case RATE_MONOTONIC_ACTIVE:
|
case RATE_MONOTONIC_ACTIVE:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user