mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-19 18:55:04 +08:00
added support for statistics on rate monotonic periods.
This commit is contained in:
@@ -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;
|
||||
@@ -139,6 +151,21 @@ rtems_status_code rtems_rate_monotonic_delete(
|
||||
Objects_Id id
|
||||
);
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
@@ -139,6 +151,21 @@ rtems_status_code rtems_rate_monotonic_delete(
|
||||
Objects_Id id
|
||||
);
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
|
||||
@@ -213,6 +213,60 @@ rtems_status_code rtems_rate_monotonic_delete(
|
||||
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
|
||||
}
|
||||
|
||||
/*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
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -139,6 +151,21 @@ rtems_status_code rtems_rate_monotonic_delete(
|
||||
Objects_Id id
|
||||
);
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
|
||||
@@ -213,6 +213,60 @@ rtems_status_code rtems_rate_monotonic_delete(
|
||||
return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */
|
||||
}
|
||||
|
||||
/*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
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user