Ticket #1636: rtems-cvs_v1.diff

File rtems-cvs_v1.diff, 57.5 KB (added by Gedare Bloom, on 08/12/10 at 18:31:59)

Patch to refactor Rate Monotonic Manager.

  • cpukit/rtems/Makefile.am

    RCS file: /usr1/CVS/rtems/cpukit/rtems/Makefile.am,v
    retrieving revision 1.52
    diff -u -p -r1.52 Makefile.am
    include_rtems_rtems_HEADERS = include/rt 
    2525    include/rtems/rtems/intr.h include/rtems/rtems/message.h \
    2626    include/rtems/rtems/modes.h include/rtems/rtems/object.h \
    2727    include/rtems/rtems/options.h include/rtems/rtems/part.h \
     28    include/rtems/rtems/periodic.h \
    2829    include/rtems/rtems/ratemon.h include/rtems/rtems/region.h \
    2930    include/rtems/rtems/rtemsapi.h include/rtems/rtems/sem.h \
    3031    include/rtems/rtems/signal.h include/rtems/rtems/status.h \
    librtems_a_SOURCES += src/tasks.c src/ta 
    7172    src/taskvariableadd.c src/taskvariabledelete.c src/taskvariableget.c \
    7273    src/taskvariable_invoke_dtor.c src/taskdata.c
    7374
     75## PERIODIC_C_FILES
     76librtems_a_SOURCES += src/periodiccancel.c src/periodicident.c \
     77    src/periodiccreate.c src/periodicperiod.c src/periodicdelete.c \
     78    src/periodicreportstatistics.c src/periodicgetstatistics.c \
     79    src/periodicresetall.c src/periodicgetstatus.c \
     80    src/periodicresetstatistics.c
     81
    7482## RATEMON_C_FILES
    7583librtems_a_SOURCES += src/ratemon.c src/ratemoncancel.c src/ratemoncreate.c \
    7684    src/ratemondelete.c src/ratemongetstatus.c src/ratemongetstatistics.c \
    7785    src/ratemonresetstatistics.c src/ratemonresetall.c \
    7886    src/ratemonreportstatistics.c src/ratemonident.c \
    79     src/ratemonperiod.c src/ratemontimeout.c src/ratemondata.c
     87    src/ratemonperiod.c src/ratemondata.c
    8088
    8189## INTR_C_FILES
    8290librtems_a_SOURCES += src/intrbody.c src/intrcatch.c
  • cpukit/rtems/preinstall.am

    RCS file: /usr1/CVS/rtems/cpukit/rtems/preinstall.am,v
    retrieving revision 1.14
    diff -u -p -r1.14 preinstall.am
    $(PROJECT_INCLUDE)/rtems/rtems/part.h: i 
    8787        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/part.h
    8888PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/part.h
    8989
     90$(PROJECT_INCLUDE)/rtems/rtems/periodic.h: include/rtems/rtems/periodic.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
     91        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/periodic.h
     92PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/periodic.h
     93
    9094$(PROJECT_INCLUDE)/rtems/rtems/ratemon.h: include/rtems/rtems/ratemon.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
    9195        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/ratemon.h
    9296PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/ratemon.h
  • cpukit/rtems/include/rtems/rtems/ratemon.h

    RCS file: /usr1/CVS/rtems/cpukit/rtems/include/rtems/rtems/ratemon.h,v
    retrieving revision 1.42
    diff -u -p -r1.42 ratemon.h
     
    2828#ifndef _RTEMS_RTEMS_RATEMON_H
    2929#define _RTEMS_RTEMS_RATEMON_H
    3030
    31 /**
    32  *  This constant is defined to extern most of the time when using
    33  *  this header file.  However by defining it to nothing, the data
    34  *  declared in this header file can be instantiated.  This is done
    35  *  in a single per manager file.
    36  */
    37 #ifndef RTEMS_RATEMON_EXTERN
    38 #define RTEMS_RATEMON_EXTERN extern
    39 #endif
    40 
    4131#include <rtems/bspIo.h>
    4232
    4333/**
     
    5949extern "C" {
    6050#endif
    6151
    62 /**
    63  *  This is the public type used for the rate monotonic timing
    64  *  statistics.
    65  */
    66 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    67   #include <rtems/score/timespec.h>
    68 
    69   typedef struct timespec rtems_rate_monotonic_period_time_t;
    70 #else
    71   typedef uint32_t rtems_rate_monotonic_period_time_t;
    72 #endif
    73 
    74 /**
    75  *  This is the internal type used for the rate monotonic timing
    76  *  statistics.
    77  */
    78 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    79   #include <rtems/score/timestamp.h>
    80 
    81   typedef Timestamp_Control Rate_monotonic_Period_time_t;
    82 #else
    83   typedef uint32_t Rate_monotonic_Period_time_t;
    84 #endif
    85 
    86 #include <rtems/score/object.h>
    87 #include <rtems/score/thread.h>
    88 #include <rtems/score/watchdog.h>
     52#include <rtems/rtems/periodic.h>
    8953#include <rtems/rtems/status.h>
    9054#include <rtems/rtems/support.h>
    9155
     56#include <rtems/score/periodic.h>
     57
    9258#include <string.h>
    9359
     60typedef rtems_periodic_period_states rtems_rate_monotonic_period_states;
    9461
    95 /**
    96  *  The following enumerated type defines the states in which a
    97  *  period may be.
    98  */
    99 typedef enum {
    100   /**
    101    * This value indicates the period is off the watchdog chain,
    102    * and has never been initialized.
    103    */
    104   RATE_MONOTONIC_INACTIVE,
    105 
    106   /**
    107    * This value indicates the period is on the watchdog chain, and
    108    * the owner is blocked waiting on it.
    109    */
    110   RATE_MONOTONIC_OWNER_IS_BLOCKING,
    111 
    112   /**
    113    * This value indicates the period is on the watchdog chain, and
    114    * running.  The owner should be executed or blocked waiting on
    115    * another object.
    116    */
    117   RATE_MONOTONIC_ACTIVE,
    118 
    119   /**
    120    * This value indicates the period is on the watchdog chain, and
    121    * has expired.  The owner should be blocked waiting for the next period.
    122    */
    123   RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING,
    124 
    125   /**
    126    * This value indicates the period is off the watchdog chain, and
    127    * has expired.  The owner is still executing and has taken too much
    128    * all time to complete this iteration of the period.
    129    */
    130   RATE_MONOTONIC_EXPIRED
    131 }   rtems_rate_monotonic_period_states;
    132 
    133 /**
    134  *  The following constant is the interval passed to the rate_monontonic_period
    135  *  directive to obtain status information.
    136  */
    137 #define RTEMS_PERIOD_STATUS       WATCHDOG_NO_TIMEOUT
    138 
    139 /**
    140  *  The following defines the PUBLIC data structure that has the
    141  *  statistics kept on each period instance.
    142  *
    143  *  @note The public structure uses struct timespec while the
    144  *        internal one uses Timestamp_Control.
    145  */
    146 typedef struct {
    147   /** This field contains the number of periods executed. */
    148   uint32_t     count;
    149   /** This field contains the number of periods missed. */
    150   uint32_t     missed_count;
    151 
    152   /** This field contains the least amount of CPU time used in a period. */
    153   rtems_thread_cpu_usage_t             min_cpu_time;
    154   /** This field contains the highest amount of CPU time used in a period. */
    155   rtems_thread_cpu_usage_t             max_cpu_time;
    156   /** This field contains the total amount of wall time used in a period. */
    157   rtems_thread_cpu_usage_t             total_cpu_time;
    158 
    159   /** This field contains the least amount of wall time used in a period. */
    160   rtems_rate_monotonic_period_time_t   min_wall_time;
    161   /** This field contains the highest amount of wall time used in a period. */
    162   rtems_rate_monotonic_period_time_t   max_wall_time;
    163   /** This field contains the total amount of CPU time used in a period. */
    164   rtems_rate_monotonic_period_time_t   total_wall_time;
    165 }  rtems_rate_monotonic_period_statistics;
    166 
    167 /**
    168  *  The following defines the INTERNAL data structure that has the
    169  *  statistics kept on each period instance.
    170  */
    171 typedef struct {
    172   /** This field contains the number of periods executed. */
    173   uint32_t     count;
    174   /** This field contains the number of periods missed. */
    175   uint32_t     missed_count;
    176 
    177   /** This field contains the least amount of CPU time used in a period. */
    178   Thread_CPU_usage_t                   min_cpu_time;
    179   /** This field contains the highest amount of CPU time used in a period. */
    180   Thread_CPU_usage_t                   max_cpu_time;
    181   /** This field contains the total amount of wall time used in a period. */
    182   Thread_CPU_usage_t                   total_cpu_time;
    183 
    184   /** This field contains the least amount of wall time used in a period. */
    185   Rate_monotonic_Period_time_t         min_wall_time;
    186   /** This field contains the highest amount of wall time used in a period. */
    187   Rate_monotonic_Period_time_t         max_wall_time;
    188   /** This field contains the total amount of CPU time used in a period. */
    189   Rate_monotonic_Period_time_t         total_wall_time;
    190 }  Rate_monotonic_Statistics;
    191 
    192 /**
    193  *  The following defines the period status structure.
    194  */
    195 typedef struct {
    196   /** This is the Id of the thread using this period. */
    197   rtems_id                             owner;
    198 
    199   /** This is the current state of this period. */
    200   rtems_rate_monotonic_period_states   state;
    201 
    202   /**
    203    *  This is the length of wall time that has passed since this period
    204    *  was last initiated.  If the period is expired or has not been initiated,
    205    *  then this field has no meaning.
    206    */
    207   rtems_rate_monotonic_period_time_t   since_last_period;
    208 
    209   /**
    210    *  This is the amount of CPU time that has been used since this period
    211    *  was last initiated.  If the period is expired or has not been initiated,
    212    *  then this field has no meaning.
    213    */
    214   rtems_thread_cpu_usage_t             executed_since_last_period;
    215 }  rtems_rate_monotonic_period_status;
    216 
    217 /**
    218  *  The following structure defines the control block used to manage
    219  *  each period.
    220  */
    221 typedef struct {
    222   /** This field is the object management portion of a Period instance. */
    223   Objects_Control                         Object;
    224 
    225   /** This is the timer used to provide the unblocking mechanism. */
    226   Watchdog_Control                        Timer;
    227 
    228   /** This field indicates the current state of the period. */
    229   rtems_rate_monotonic_period_states      state;
    230 
    231   /**
    232    * This field contains the length of the next period to be
    233    * executed.
    234    */
    235   uint32_t                                next_length;
    236 
    237   /**
    238    * This field contains a pointer to the TCB for the thread
    239    * which owns and uses this period instance.
    240    */
    241   Thread_Control                         *owner;
    242 
    243   /**
    244    * This field contains the cpu usage value of the owning thread when
    245    * the period was initiated.  It is used to compute the period's
    246    * statistics.
    247    */
    248   Thread_CPU_usage_t                      cpu_usage_period_initiated;
    249 
    250   /**
    251    * This field contains the wall time value when the period
    252    * was initiated.  It is used to compute the period's statistics.
    253    */
    254   Rate_monotonic_Period_time_t            time_period_initiated;
    255 
    256   /**
    257    * This field contains the statistics maintained for the period.
    258    */
    259   Rate_monotonic_Statistics               Statistics;
    260 }   Rate_monotonic_Control;
     62typedef rtems_periodic_period_statistics rtems_rate_monotonic_period_statistics;
    26163
    262 /**
    263  *  @brief Rate Monotonic Period Class Management Structure
    264  *
    265  *  This instance of Objects_Information is used to manage the
    266  *  set of rate monotonic period instances.
    267  */
    268 RTEMS_RATEMON_EXTERN Objects_Information _Rate_monotonic_Information;
     64typedef rtems_periodic_period_status rtems_rate_monotonic_period_status;
    26965
    270 /**
    271  *  @brief Rate Monotonic Manager Initialization
    272  *
    273  *  This routine performs the initialization necessary for this manager.
    274  */
    275 void _Rate_monotonic_Manager_initialization(void);
     66typedef Periodic_Control Rate_monotonic_Control;
    27667
    27768/**
    27869 *  @brief rtems_rate_monotonic_create
    rtems_status_code rtems_rate_monotonic_p 
    393184);
    394185
    395186/**
    396  *  @brief _Rate_monotonic_Timeout
    397  *
    398  *  This routine is invoked when the period represented
    399  *  by ID expires.  If the thread which owns this period is blocked
    400  *  waiting for the period to expire, then it is readied and the
    401  *  period is restarted.  If the owning thread is not waiting for the
    402  *  period to expire, then the period is placed in the EXPIRED
    403  *  state and not restarted.
    404  */
    405 void _Rate_monotonic_Timeout(
    406   rtems_id    id,
    407   void       *ignored
    408 );
    409 
    410 /**
    411  *  @brief _Rate_monotonic_Get_status(
    412  *
    413  *  This routine is invoked to compute the elapsed wall time and cpu
    414  *  time for a period.
    415  *
    416  *  @param[in] the_period points to the period being operated upon.
    417  *  @param[out] wall_since_last_period is set to the wall time elapsed
    418  *              since the period was initiated.
    419  *  @param[out] cpu_since_last_period is set to the cpu time used by the
    420  *              owning thread since the period was initiated.
    421  *
    422  *  @return This routine returns true if the status can be determined
    423  *          and false otherwise.
    424  */
    425 bool _Rate_monotonic_Get_status(
    426   Rate_monotonic_Control        *the_period,
    427   Rate_monotonic_Period_time_t  *wall_since_last_period,
    428   Thread_CPU_usage_t            *cpu_since_last_period
    429 );
    430 
    431 /**
    432  *  @brief _Rate_monotonic_Initiate_statistics(
    433  *
    434  *  This routine is invoked when a period is initiated via an explicit
    435  *  call to rtems_rate_monotonic_period for the period's first iteration
    436  *  or from _Rate_monotonic_Timeout for period iterations 2-n.
    437  *
    438  *  @param[in] the_period points to the period being operated upon.
    439  */
    440 void _Rate_monotonic_Initiate_statistics(
    441   Rate_monotonic_Control *the_period
    442 );
    443 
    444 /**
    445  *  @brief _Rate_monotonic_Reset_wall_time_statistics
    446  *
    447  *  This method resets the statistics information for a period instance.
    448  */
    449 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    450   #define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
    451      do { \
    452         /* set the minimums to a large value */ \
    453         _Timestamp_Set( \
    454           &(_the_period)->Statistics.min_wall_time, \
    455           0x7fffffff, \
    456           0x7fffffff \
    457         ); \
    458      } while (0)
    459 #else
    460   #define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
    461      do { \
    462         /* set the minimum to a large value */ \
    463         (_the_period)->Statistics.min_wall_time = 0xffffffff; \
    464      } while (0)
    465 #endif
    466 
    467 /**
    468  *  @brief Rate_monotonic_Reset_cpu_use_statistics
     187 *  @brief Rate Monotonic Manager Initialization
    469188 *
    470  *  This helper method resets the period CPU usage statistics structure.
     189 *  This routine performs the initialization necessary for this manager.
    471190 */
    472 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    473   #define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
    474      do { \
    475         /* set the minimums to a large value */ \
    476         _Timestamp_Set( \
    477           &(_the_period)->Statistics.min_cpu_time, \
    478           0x7fffffff, \
    479           0x7fffffff \
    480         ); \
    481      } while (0)
    482 #else
    483   #define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
    484      do { \
    485         /* set the minimum to a large value */ \
    486         (_the_period)->Statistics.min_cpu_time = 0xffffffff; \
    487      } while (0)
    488 #endif
     191void _Rate_monotonic_Manager_initialization(void);
    489192
    490 /**
    491  *  @brief Rate_monotonic_Reset_statistics
    492  *
    493  *  This helper method resets the period wall time statistics structure.
    494  */
    495 #define _Rate_monotonic_Reset_statistics( _the_period ) \
    496   do { \
    497     memset( \
    498       &(_the_period)->Statistics, \
    499       0, \
    500       sizeof( rtems_rate_monotonic_period_statistics ) \
    501     ); \
    502     _Rate_monotonic_Reset_cpu_use_statistics( _the_period ); \
    503     _Rate_monotonic_Reset_wall_time_statistics( _the_period ); \
    504   } while (0)
    505193
    506194#ifndef __RTEMS_APPLICATION__
    507195#include <rtems/rtems/ratemon.inl>
  • cpukit/rtems/inline/rtems/rtems/ratemon.inl

    RCS file: /usr1/CVS/rtems/cpukit/rtems/inline/rtems/rtems/ratemon.inl,v
    retrieving revision 1.16
    diff -u -p -r1.16 ratemon.inl
     
    2727 *  @{
    2828 */
    2929
    30 /**
    31  *  @brief Rate_monotonic_Allocate
    32  *
    33  *  This function allocates a period control block from
    34  *  the inactive chain of free period control blocks.
    35  */
    36 RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void )
    37 {
    38   return (Rate_monotonic_Control *)
    39     _Objects_Allocate( &_Rate_monotonic_Information );
    40 }
    4130
    42 /**
    43  *  @brief Rate_monotonic_Free
    44  *
    45  *  This routine allocates a period control block from
    46  *  the inactive chain of free period control blocks.
    47  */
    48 RTEMS_INLINE_ROUTINE void _Rate_monotonic_Free (
    49   Rate_monotonic_Control *the_period
    50 )
    51 {
    52   _Objects_Free( &_Rate_monotonic_Information, &the_period->Object );
    53 }
    54 
    55 /**
    56  *  @brief Rate_monotonic_Get
    57  *
    58  *  This function maps period IDs to period control blocks.
    59  *  If ID corresponds to a local period, then it returns
    60  *  the_period control pointer which maps to ID and location
    61  *  is set to OBJECTS_LOCAL.  Otherwise, location is set
    62  *  to OBJECTS_ERROR and the_period is undefined.
    63  */
    64 RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get (
    65   Objects_Id         id,
    66   Objects_Locations *location
    67 )
    68 {
    69   return (Rate_monotonic_Control *)
    70     _Objects_Get( &_Rate_monotonic_Information, id, location );
    71 }
    72 
    73 /**
    74  *  @brief Rate_monotonic_Is_active
    75  *
    76  *  This function returns TRUE if the_period is in the ACTIVE state,
    77  *  and FALSE otherwise.
    78  */
    79 RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_active (
    80   Rate_monotonic_Control *the_period
    81 )
    82 {
    83   return (the_period->state == RATE_MONOTONIC_ACTIVE);
    84 }
    85 
    86 /**
    87  *  @brief Rate_monotonic_Is_inactive
    88  *
    89  *  This function returns TRUE if the_period is in the ACTIVE state,
    90  *  and FALSE otherwise.
    91  */
    92 RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_inactive (
    93   Rate_monotonic_Control *the_period
    94 )
    95 {
    96   return (the_period->state == RATE_MONOTONIC_INACTIVE);
    97 }
    98 
    99 /**
    100  *  @brief Rate_monotonic_Is_expired
    101  *
    102  *  This function returns TRUE if the_period is in the EXPIRED state,
    103  *  and FALSE otherwise.
    104  */
    105 RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_expired (
    106   Rate_monotonic_Control *the_period
    107 )
    108 {
    109   return (the_period->state == RATE_MONOTONIC_EXPIRED);
    110 }
    111 
    112 /**
    113  *  @brief Rate_monotonic_Is_null
    114  *
    115  *  This function returns TRUE if the_period is NULL and FALSE otherwise.
    116  */
    117 RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_null (
    118   Rate_monotonic_Control *the_period
    119 )
    120 {
    121   return (the_period == NULL);
    122 }
    12331
    12432/**@}*/
    12533
  • cpukit/rtems/src/ratemon.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemon.c,v
    retrieving revision 1.24
    diff -u -p -r1.24 ratemon.c
     
    2222#include <rtems/rtems/support.h>
    2323#include <rtems/score/isr.h>
    2424#include <rtems/score/object.h>
     25#include <rtems/rtems/periodic.h>
    2526#include <rtems/rtems/ratemon.h>
    2627#include <rtems/score/thread.h>
    2728
     
    4243
    4344void _Rate_monotonic_Manager_initialization(void)
    4445{
    45   _Objects_Initialize_information(
    46     &_Rate_monotonic_Information,    /* object information table */
    47     OBJECTS_CLASSIC_API,             /* object API */
    48     OBJECTS_RTEMS_PERIODS,           /* object class */
    49     Configuration_RTEMS_API.maximum_periods,
    50                                      /* maximum objects of this class */
    51     sizeof( Rate_monotonic_Control ),/* size of this object's control block */
    52     false,                           /* true if the name is a string */
    53     RTEMS_MAXIMUM_NAME_LENGTH        /* maximum length of an object name */
    54 #if defined(RTEMS_MULTIPROCESSING)
    55     ,
    56     false,                           /* true if this is a global object class */
    57     NULL                             /* Proxy extraction support callout */
    58 #endif
    59   );
     46  _Periodic_Manager_initialization();
    6047}
  • cpukit/rtems/src/ratemoncancel.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemoncancel.c,v
    retrieving revision 1.10
    diff -u -p -r1.10 ratemoncancel.c
     
    2020#include <rtems/rtems/support.h>
    2121#include <rtems/score/isr.h>
    2222#include <rtems/score/object.h>
     23#include <rtems/rtems/periodic.h>
    2324#include <rtems/rtems/ratemon.h>
    2425#include <rtems/score/thread.h>
    2526
    rtems_status_code rtems_rate_monotonic_c 
    4142  rtems_id id
    4243)
    4344{
    44   Rate_monotonic_Control *the_period;
    45   Objects_Locations       location;
    46 
    47   the_period = _Rate_monotonic_Get( id, &location );
    48   switch ( location ) {
    49 
    50     case OBJECTS_LOCAL:
    51       if ( !_Thread_Is_executing( the_period->owner ) ) {
    52         _Thread_Enable_dispatch();
    53         return RTEMS_NOT_OWNER_OF_RESOURCE;
    54       }
    55       (void) _Watchdog_Remove( &the_period->Timer );
    56       the_period->state = RATE_MONOTONIC_INACTIVE;
    57       _Thread_Enable_dispatch();
    58       return RTEMS_SUCCESSFUL;
    59 
    60 #if defined(RTEMS_MULTIPROCESSING)
    61     case OBJECTS_REMOTE:
    62 #endif
    63     case OBJECTS_ERROR:
    64       break;
    65   }
    66 
    67   return RTEMS_INVALID_ID;
     45  return rtems_periodic_cancel(id);
    6846}
  • cpukit/rtems/src/ratemoncreate.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemoncreate.c,v
    retrieving revision 1.10
    diff -u -p -r1.10 ratemoncreate.c
     
    2020#include <rtems/rtems/support.h>
    2121#include <rtems/score/isr.h>
    2222#include <rtems/score/object.h>
     23#include <rtems/rtems/periodic.h>
    2324#include <rtems/rtems/ratemon.h>
    2425#include <rtems/score/thread.h>
    2526
    rtems_status_code rtems_rate_monotonic_c 
    4546  rtems_id   *id
    4647)
    4748{
    48   Rate_monotonic_Control *the_period;
    49 
    50   if ( !rtems_is_name_valid( name ) )
    51     return RTEMS_INVALID_NAME;
    52 
    53   if ( !id )
    54     return RTEMS_INVALID_ADDRESS;
    55 
    56   _Thread_Disable_dispatch();            /* to prevent deletion */
    57 
    58   the_period = _Rate_monotonic_Allocate();
    59 
    60   if ( !the_period ) {
    61     _Thread_Enable_dispatch();
    62     return RTEMS_TOO_MANY;
    63   }
    64 
    65   the_period->owner = _Thread_Executing;
    66   the_period->state = RATE_MONOTONIC_INACTIVE;
    67 
    68   _Watchdog_Initialize( &the_period->Timer, NULL, 0, NULL );
    69 
    70   _Rate_monotonic_Reset_statistics( the_period );
    71 
    72   _Objects_Open(
    73     &_Rate_monotonic_Information,
    74     &the_period->Object,
    75     (Objects_Name) name
    76   );
    77 
    78   *id = the_period->Object.id;
    79   _Thread_Enable_dispatch();
    80   return RTEMS_SUCCESSFUL;
     49  return rtems_periodic_create( name, id );
    8150}
  • cpukit/rtems/src/ratemondata.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemondata.c,v
    retrieving revision 1.1
    diff -u -p -r1.1 ratemondata.c
     
    99 *  http://www.rtems.com/license/LICENSE.
    1010 *
    1111 *  $Id: ratemondata.c,v 1.1 2007/05/21 23:19:20 joel Exp $
     12 *
     13 *  Note: this file is deprecated.
    1214 */
    1315
    1416#if HAVE_CONFIG_H
  • cpukit/rtems/src/ratemondelete.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemondelete.c,v
    retrieving revision 1.9
    diff -u -p -r1.9 ratemondelete.c
     
    2020#include <rtems/rtems/support.h>
    2121#include <rtems/score/isr.h>
    2222#include <rtems/score/object.h>
     23#include <rtems/rtems/periodic.h>
    2324#include <rtems/rtems/ratemon.h>
    2425#include <rtems/score/thread.h>
    2526
    rtems_status_code rtems_rate_monotonic_d 
    4142  rtems_id id
    4243)
    4344{
    44   Rate_monotonic_Control *the_period;
    45   Objects_Locations       location;
    46 
    47   the_period = _Rate_monotonic_Get( id, &location );
    48   switch ( location ) {
    49 
    50     case OBJECTS_LOCAL:
    51       _Objects_Close( &_Rate_monotonic_Information, &the_period->Object );
    52       (void) _Watchdog_Remove( &the_period->Timer );
    53       the_period->state = RATE_MONOTONIC_INACTIVE;
    54       _Rate_monotonic_Free( the_period );
    55       _Thread_Enable_dispatch();
    56       return RTEMS_SUCCESSFUL;
    57 
    58 #if defined(RTEMS_MULTIPROCESSING)
    59     case OBJECTS_REMOTE:            /* should never return this */
    60 #endif
    61     case OBJECTS_ERROR:
    62       break;
    63   }
    64 
    65   return RTEMS_INVALID_ID;
     45  return rtems_periodic_delete(id);
    6646}
  • cpukit/rtems/src/ratemongetstatistics.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemongetstatistics.c,v
    retrieving revision 1.7
    diff -u -p -r1.7 ratemongetstatistics.c
     
    2020#include <rtems/rtems/support.h>
    2121#include <rtems/score/isr.h>
    2222#include <rtems/score/object.h>
     23#include <rtems/rtems/periodic.h>
    2324#include <rtems/rtems/ratemon.h>
    2425#include <rtems/score/thread.h>
    2526
    rtems_status_code rtems_rate_monotonic_g 
    4546  rtems_rate_monotonic_period_statistics *statistics
    4647)
    4748{
    48   Objects_Locations                        location;
    49   Rate_monotonic_Control                  *the_period;
    50   rtems_rate_monotonic_period_statistics  *dst;
    51   Rate_monotonic_Statistics               *src;
    52 
    53   if ( !statistics )
    54     return RTEMS_INVALID_ADDRESS;
    55 
    56   the_period = _Rate_monotonic_Get( id, &location );
    57   switch ( location ) {
    58 
    59     case OBJECTS_LOCAL:
    60       dst = statistics;
    61       src = &the_period->Statistics;
    62       dst->count        = src->count;
    63       dst->missed_count = src->missed_count;
    64       #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    65         _Timestamp_To_timespec( &src->min_cpu_time,   &dst->min_cpu_time );
    66         _Timestamp_To_timespec( &src->max_cpu_time,   &dst->max_cpu_time );
    67         _Timestamp_To_timespec( &src->total_cpu_time, &dst->total_cpu_time );
    68         _Timestamp_To_timespec( &src->min_wall_time,   &dst->min_wall_time );
    69         _Timestamp_To_timespec( &src->max_wall_time,   &dst->max_wall_time );
    70         _Timestamp_To_timespec( &src->total_wall_time, &dst->total_wall_time );
    71       #else
    72         dst->min_cpu_time    = src->min_cpu_time;
    73         dst->max_cpu_time    = src->max_cpu_time;
    74         dst->total_cpu_time  = src->total_cpu_time;
    75         dst->min_wall_time   = src->min_wall_time;
    76         dst->max_wall_time   = src->max_wall_time;
    77         dst->total_wall_time = src->total_wall_time;
    78       #endif
    79 
    80       _Thread_Enable_dispatch();
    81       return RTEMS_SUCCESSFUL;
    82 
    83 #if defined(RTEMS_MULTIPROCESSING)
    84     case OBJECTS_REMOTE:            /* should never return this */
    85 #endif
    86     case OBJECTS_ERROR:
    87       break;
    88   }
    89 
    90   return RTEMS_INVALID_ID;
     49  return rtems_periodic_get_statistics( id, statistics );
    9150}
  • cpukit/rtems/src/ratemongetstatus.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemongetstatus.c,v
    retrieving revision 1.18
    diff -u -p -r1.18 ratemongetstatus.c
     
    2020#include <rtems/rtems/support.h>
    2121#include <rtems/score/isr.h>
    2222#include <rtems/score/object.h>
     23#include <rtems/rtems/periodic.h>
    2324#include <rtems/rtems/ratemon.h>
    2425#include <rtems/score/thread.h>
    2526
    rtems_status_code rtems_rate_monotonic_g 
    4950  rtems_rate_monotonic_period_status *status
    5051)
    5152{
    52   Thread_CPU_usage_t             executed;
    53   Objects_Locations              location;
    54   Rate_monotonic_Period_time_t   since_last_period;
    55   Rate_monotonic_Control        *the_period;
    56   bool                           valid_status;
    57 
    58   if ( !status )
    59     return RTEMS_INVALID_ADDRESS;
    60 
    61   the_period = _Rate_monotonic_Get( id, &location );
    62   switch ( location ) {
    63 
    64     case OBJECTS_LOCAL:
    65       status->owner = the_period->owner->Object.id;
    66       status->state = the_period->state;
    67 
    68       /*
    69        *  If the period is inactive, there is no information.
    70        */
    71       if ( status->state == RATE_MONOTONIC_INACTIVE ) {
    72         #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    73           _Timespec_Set_to_zero( &status->since_last_period );
    74           _Timespec_Set_to_zero( &status->executed_since_last_period );
    75         #else
    76           status->since_last_period = 0;
    77           status->executed_since_last_period = 0;
    78         #endif
    79 
    80       } else {
    81 
    82         /*
    83          *  Grab the current status.
    84          */
    85         valid_status =
    86           _Rate_monotonic_Get_status(
    87             the_period, &since_last_period, &executed
    88           );
    89         if (!valid_status) {
    90           _Thread_Enable_dispatch();
    91           return RTEMS_NOT_DEFINED;
    92         }
    93 
    94         #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    95           _Timestamp_To_timespec(
    96             &since_last_period, &status->since_last_period
    97           );
    98           _Timestamp_To_timespec(
    99             &executed, &status->executed_since_last_period
    100           );
    101         #else
    102           status->since_last_period = since_last_period;
    103           status->executed_since_last_period = executed;
    104         #endif
    105       }
    106 
    107       _Thread_Enable_dispatch();
    108       return RTEMS_SUCCESSFUL;
    109 
    110 #if defined(RTEMS_MULTIPROCESSING)
    111     case OBJECTS_REMOTE:            /* should never return this */
    112 #endif
    113     case OBJECTS_ERROR:
    114       break;
    115   }
    116 
    117   return RTEMS_INVALID_ID;
     53  return rtems_periodic_get_status( id, status );
    11854}
  • cpukit/rtems/src/ratemonident.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemonident.c,v
    retrieving revision 1.11
    diff -u -p -r1.11 ratemonident.c
     
    2020#include <rtems/rtems/support.h>
    2121#include <rtems/score/isr.h>
    2222#include <rtems/score/object.h>
     23#include <rtems/rtems/periodic.h>
    2324#include <rtems/rtems/ratemon.h>
    2425#include <rtems/score/thread.h>
    2526
    rtems_status_code rtems_rate_monotonic_i 
    4546  rtems_id   *id
    4647)
    4748{
    48   Objects_Name_or_id_lookup_errors  status;
    49 
    50   status = _Objects_Name_to_id_u32(
    51     &_Rate_monotonic_Information,
    52     name,
    53     OBJECTS_SEARCH_LOCAL_NODE,
    54     id
    55   );
    56 
    57   return _Status_Object_name_errors_to_status[ status ];
     49  return rtems_periodic_ident( name, id );
    5850}
  • cpukit/rtems/src/ratemonperiod.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemonperiod.c,v
    retrieving revision 1.29
    diff -u -p -r1.29 ratemonperiod.c
     
    11/*
    2  *  Rate Monotonic Manager - Period Blocking and Status
     2 *  Rate Monotonic Manager - Period Blocking
    33 *
    44 *  COPYRIGHT (c) 1989-2010.
    55 *  On-Line Applications Research Corporation (OAR).
     
    2020#include <rtems/rtems/support.h>
    2121#include <rtems/score/isr.h>
    2222#include <rtems/score/object.h>
     23#include <rtems/rtems/periodic.h>
    2324#include <rtems/rtems/ratemon.h>
    2425#include <rtems/score/thread.h>
    2526
    26 bool _Rate_monotonic_Get_status(
    27   Rate_monotonic_Control        *the_period,
    28   Rate_monotonic_Period_time_t  *wall_since_last_period,
    29   Thread_CPU_usage_t            *cpu_since_last_period
    30 )
    31 {
    32   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    33     Timestamp_Control        uptime;
    34   #endif
    35     Thread_Control          *owning_thread = the_period->owner;
    36     Thread_CPU_usage_t       used;
    37 
    38   /*
    39    *  Determine elapsed wall time since period initiated.
    40    */
    41   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    42     _TOD_Get_uptime( &uptime );
    43     _Timestamp_Subtract(
    44       &the_period->time_period_initiated, &uptime, wall_since_last_period
    45     );
    46   #else
    47     *wall_since_last_period =
    48       _Watchdog_Ticks_since_boot - the_period->time_period_initiated;
    49   #endif
    50 
    51   /*
    52    *  Determine cpu usage since period initiated.
    53    */
    54   used = owning_thread->cpu_time_used;
    55 
    56   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    57     if (owning_thread == _Thread_Executing) {
    58 
    59       Thread_CPU_usage_t ran;
    60 
    61       /* How much time time since last context switch */
    62       _Timestamp_Subtract(
    63         &_Thread_Time_of_last_context_switch, &uptime, &ran
    64       );
    65 
    66       /* cpu usage += ran */
    67       _Timestamp_Add_to( &used, &ran );
    68 
    69       /*
    70        *  The cpu usage info was reset while executing.  Can't
    71        *  determine a status.
    72        */
    73       if (_Timestamp_Less_than(&used, &the_period->cpu_usage_period_initiated))
    74         return false;
    75 
    76        /* used = current cpu usage - cpu usage at start of period */
    77       _Timestamp_Subtract(
    78          &the_period->cpu_usage_period_initiated,
    79          &used,
    80          cpu_since_last_period
    81       );
    82     }
    83   #else
    84       /*
    85        *  The cpu usage info was reset while executing.  Can't
    86        *  determine a status.
    87        */
    88       if (used < the_period->cpu_usage_period_initiated)
    89         return false;
    90 
    91       *cpu_since_last_period = used - the_period->cpu_usage_period_initiated;
    92   #endif
    93   return true;
    94 }
    95 
    96 void _Rate_monotonic_Initiate_statistics(
    97   Rate_monotonic_Control *the_period
    98 )
    99 {
    100   Thread_Control *owning_thread = the_period->owner;
    101 
    102   /*
    103    *  If using nanosecond statistics, we need to obtain the uptime.
    104    */
    105   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    106     Timestamp_Control  uptime;
    107 
    108     _TOD_Get_uptime( &uptime );
    109   #endif
    110 
    111   /*
    112    *  Set the starting point and the CPU time used for the statistics.
    113    */
    114   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    115     the_period->time_period_initiated = uptime;
    116   #else
    117     the_period->time_period_initiated = _Watchdog_Ticks_since_boot;
    118   #endif
    119 
    120   the_period->cpu_usage_period_initiated = owning_thread->cpu_time_used;
    121 
    122   /*
    123    *  If using nanosecond statistics and the period's thread is currently
    124    *  executing, then we need to take into account how much time the
    125    *  executing thread has run since the last context switch.  When this
    126    *  routine is invoked from rtems_rate_monotonic_period, the owner will
    127    *  be the executing thread.  When this routine is invoked from
    128    *  _Rate_monotonic_Timeout, it will not.
    129    */
    130   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    131     if (owning_thread == _Thread_Executing) {
    132 
    133       rtems_thread_cpu_usage_t ran;
    134 
    135       /*
    136        *  Adjust the CPU time used to account for the time since last
    137        *  context switch.
    138        */
    139       _Timespec_Subtract(
    140         &_Thread_Time_of_last_context_switch, &uptime, &ran
    141       );
    142 
    143       _Timespec_Add_to( &the_period->cpu_usage_period_initiated, &ran );
    144     }
    145   #endif
    146 }
    147 
    148 void _Rate_monotonic_Update_statistics(
    149   Rate_monotonic_Control    *the_period
    150 )
    151 {
    152   Thread_CPU_usage_t              executed;
    153   Rate_monotonic_Period_time_t    since_last_period;
    154   Rate_monotonic_Statistics      *stats;
    155   bool                            valid_status;
    156 
    157   /*
    158    *  Assume we are only called in states where it is appropriate
    159    *  to update the statistics.  This should only be RATE_MONOTONIC_ACTIVE
    160    *  and RATE_MONOTONIC_EXPIRED.
    161    */
    162 
    163   /*
    164    *  Update the counts.
    165    */
    166   stats = &the_period->Statistics;
    167   stats->count++;
    168 
    169   if ( the_period->state == RATE_MONOTONIC_EXPIRED )
    170     stats->missed_count++;
    171 
    172   /*
    173    *  Grab status for time statistics.
    174    */
    175   valid_status =
    176     _Rate_monotonic_Get_status( the_period, &since_last_period, &executed );
    177   if (!valid_status)
    178     return;
    179 
    180   /*
    181    *  Update CPU time
    182    */
    183   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    184     _Timestamp_Add_to( &stats->total_cpu_time, &executed );
    185 
    186     if ( _Timestamp_Less_than( &executed, &stats->min_cpu_time ) )
    187       stats->min_cpu_time = executed;
    188 
    189     if ( _Timestamp_Greater_than( &executed, &stats->max_cpu_time ) )
    190       stats->max_cpu_time = executed;
    191   #else
    192     stats->total_cpu_time  += executed;
    193 
    194     if ( executed < stats->min_cpu_time )
    195       stats->min_cpu_time = executed;
    196 
    197     if ( executed > stats->max_cpu_time )
    198       stats->max_cpu_time = executed;
    199   #endif
    200 
    201   /*
    202    *  Update Wall time
    203    */
    204   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    205     _Timestamp_Add_to( &stats->total_wall_time, &since_last_period );
    206 
    207     if ( _Timestamp_Less_than( &since_last_period, &stats->min_wall_time ) )
    208       stats->min_wall_time = since_last_period;
    209 
    210     if ( _Timestamp_Greater_than( &since_last_period, &stats->max_wall_time ) )
    211       stats->max_wall_time = since_last_period;
    212   #else
    213 
    214     /* Sanity check wall time */
    215     if ( since_last_period < executed )
    216       since_last_period = executed;
    217 
    218     stats->total_wall_time += since_last_period;
    219 
    220     if ( since_last_period < stats->min_wall_time )
    221       stats->min_wall_time = since_last_period;
    222 
    223     if ( since_last_period > stats->max_wall_time )
    224       stats->max_wall_time = since_last_period;
    225   #endif
    226 }
    227 
    228 
    22927/*PAGE
    23028 *
    23129 *  rtems_rate_monotonic_period
    rtems_status_code rtems_rate_monotonic_p 
    24644  rtems_interval length
    24745)
    24846{
    249   Rate_monotonic_Control              *the_period;
    250   Objects_Locations                    location;
    251   rtems_status_code                    return_value;
    252   rtems_rate_monotonic_period_states   local_state;
    253   ISR_Level                            level;
    254 
    255   the_period = _Rate_monotonic_Get( id, &location );
    256 
    257   switch ( location ) {
    258     case OBJECTS_LOCAL:
    259       if ( !_Thread_Is_executing( the_period->owner ) ) {
    260         _Thread_Enable_dispatch();
    261         return RTEMS_NOT_OWNER_OF_RESOURCE;
    262       }
    263 
    264       if ( length == RTEMS_PERIOD_STATUS ) {
    265         switch ( the_period->state ) {
    266           case RATE_MONOTONIC_INACTIVE:
    267             return_value = RTEMS_NOT_DEFINED;
    268             break;
    269           case RATE_MONOTONIC_EXPIRED:
    270           case RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING:
    271             return_value = RTEMS_TIMEOUT;
    272             break;
    273           case RATE_MONOTONIC_ACTIVE:
    274           default:              /* unreached -- only to remove warnings */
    275             return_value = RTEMS_SUCCESSFUL;
    276             break;
    277         }
    278         _Thread_Enable_dispatch();
    279         return( return_value );
    280       }
    281 
    282       _ISR_Disable( level );
    283       if ( the_period->state == RATE_MONOTONIC_INACTIVE ) {
    284         _ISR_Enable( level );
    285 
    286         /*
    287          *  Baseline statistics information for the beginning of a period.
    288          */
    289         _Rate_monotonic_Initiate_statistics( the_period );
    290 
    291         the_period->state = RATE_MONOTONIC_ACTIVE;
    292         _Watchdog_Initialize(
    293           &the_period->Timer,
    294           _Rate_monotonic_Timeout,
    295           id,
    296           NULL
    297         );
    298 
    299         the_period->next_length = length;
    300 
    301         _Watchdog_Insert_ticks( &the_period->Timer, length );
    302         _Thread_Enable_dispatch();
    303         return RTEMS_SUCCESSFUL;
    304       }
    305 
    306       if ( the_period->state == RATE_MONOTONIC_ACTIVE ) {
    307         /*
    308          *  Update statistics from the concluding period.
    309          */
    310         _Rate_monotonic_Update_statistics( the_period );
    311 
    312         /*
    313          *  This tells the _Rate_monotonic_Timeout that this task is
    314          *  in the process of blocking on the period and that we
    315          *  may be changing the length of the next period.
    316          */
    317         the_period->state = RATE_MONOTONIC_OWNER_IS_BLOCKING;
    318         the_period->next_length = length;
    319 
    320         _ISR_Enable( level );
    321 
    322         _Thread_Executing->Wait.id = the_period->Object.id;
    323         _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD );
    324 
    325         /*
    326          *  Did the watchdog timer expire while we were actually blocking
    327          *  on it?
    328          */
    329         _ISR_Disable( level );
    330           local_state = the_period->state;
    331           the_period->state = RATE_MONOTONIC_ACTIVE;
    332         _ISR_Enable( level );
    333 
    334         /*
    335          *  If it did, then we want to unblock ourself and continue as
    336          *  if nothing happen.  The period was reset in the timeout routine.
    337          */
    338         if ( local_state == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING )
    339           _Thread_Clear_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD );
    340 
    341         _Thread_Enable_dispatch();
    342         return RTEMS_SUCCESSFUL;
    343       }
    344 
    345       if ( the_period->state == RATE_MONOTONIC_EXPIRED ) {
    346         /*
    347          *  Update statistics from the concluding period
    348          */
    349         _Rate_monotonic_Update_statistics( the_period );
    350 
    351         _ISR_Enable( level );
    352 
    353         the_period->state = RATE_MONOTONIC_ACTIVE;
    354         the_period->next_length = length;
    355 
    356         _Watchdog_Insert_ticks( &the_period->Timer, length );
    357         _Thread_Enable_dispatch();
    358         return RTEMS_TIMEOUT;
    359       }
    360 
    361       /*
    362        *  These should never happen so just return invalid Id.
    363        *    - RATE_MONOTONIC_OWNER_IS_BLOCKING:
    364        *    - RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING:
    365        */
    366 #if defined(RTEMS_MULTIPROCESSING)
    367     case OBJECTS_REMOTE:            /* should never return this */
    368 #endif
    369     case OBJECTS_ERROR:
    370       break;
    371   }
    372 
    373   return RTEMS_INVALID_ID;
     47  return rtems_periodic_period( id, length );
    37448}
  • cpukit/rtems/src/ratemonreportstatistics.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemonreportstatistics.c,v
    retrieving revision 1.12
    diff -u -p -r1.12 ratemonreportstatistics.c
     
    2020#include <ctype.h>
    2121#include <inttypes.h>
    2222
     23#include <rtems/rtems/periodic.h>
     24
    2325#include <rtems/bspIo.h>
    2426#include <rtems/score/timespec.h>
    2527
    26 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    27   /* We print to 1/10's of milliseconds */
    28   #define NANOSECONDS_DIVIDER 1000
    29   #define PERCENT_FMT     "%04" PRId32
    30   #define NANOSECONDS_FMT "%06" PRId32
    31 #endif
    32 
    3328/*
    3429 *  This directive allows a thread to print the statistics information
    3530 *  on ALL period instances which have non-zero counts using printk.
    void rtems_rate_monotonic_report_statist 
    4338  rtems_printk_plugin_t  print
    4439)
    4540{
    46   rtems_status_code                      status;
    47   rtems_id                               id;
    48   rtems_rate_monotonic_period_statistics the_stats;
    49   rtems_rate_monotonic_period_status     the_status;
    50   char                                   name[5];
    51 
    52   if ( !print )
    53     return;
    54 
    55   (*print)( context, "Period information by period\n" );
    56   #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    57     (*print)( context, "--- CPU times are in seconds ---\n" );
    58     (*print)( context, "--- Wall times are in seconds ---\n" );
    59   #endif
    60 /*
    61 Layout by columns -- in memory of Hollerith :)
    62 
    63 1234567890123456789012345678901234567890123456789012345678901234567890123456789\
    64    ID     OWNER COUNT MISSED X
    65 ididididid NNNN ccccc mmmmmm X
    66 
    67   Uncomment the following if you are tinkering with the formatting.
    68   Be sure to test the various cases.
    69   (*print)( context,"\
    70 1234567890123456789012345678901234567890123456789012345678901234567890123456789\
    71 \n");
    72 */
    73   (*print)( context, "   ID     OWNER COUNT MISSED     "
    74        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    75           "     "
    76        #endif
    77           "CPU TIME     "
    78        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    79           "          "
    80        #endif
    81           "   WALL TIME\n"
    82   );
    83   (*print)( context, "                               "
    84        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    85           "     "
    86        #endif
    87           "MIN/MAX/AVG    "
    88        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    89           "          "
    90        #endif
    91           "  MIN/MAX/AVG\n"
    92   );
    93 
    94   /*
    95    * Cycle through all possible ids and try to report on each one.  If it
    96    * is a period that is inactive, we just get an error back.  No big deal.
    97    */
    98   for ( id=_Rate_monotonic_Information.minimum_id ;
    99         id <= _Rate_monotonic_Information.maximum_id ;
    100         id++ ) {
    101     status = rtems_rate_monotonic_get_statistics( id, &the_stats );
    102     if ( status != RTEMS_SUCCESSFUL )
    103       continue;
    104 
    105     /* If the above passed, so should this but check it anyway */
    106     status = rtems_rate_monotonic_get_status( id, &the_status );
    107     #if defined(RTEMS_DEBUG)
    108       if ( status != RTEMS_SUCCESSFUL )
    109         continue;
    110     #endif
    111 
    112     rtems_object_get_name( the_status.owner, sizeof(name), name );
    113 
    114     /*
    115      *  Print part of report line that is not dependent on granularity
    116      */
    117     (*print)( context,
    118       "0x%08" PRIx32 " %4s %5" PRId32 " %6" PRId32 " ",
    119       id, name,
    120       the_stats.count, the_stats.missed_count
    121     );
    122 
    123     /*
    124      *  If the count is zero, don't print statistics
    125      */
    126     if (the_stats.count == 0) {
    127       (*print)( context, "\n" );
    128       continue;
    129     }
    130 
    131     /*
    132      *  print CPU Usage part of statistics
    133      */
    134     {
    135     #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    136       struct timespec  cpu_average;
    137       struct timespec *min_cpu = &the_stats.min_cpu_time;
    138       struct timespec *max_cpu = &the_stats.max_cpu_time;
    139       struct timespec *total_cpu = &the_stats.total_cpu_time;
    140 
    141       _Timespec_Divide_by_integer( total_cpu, the_stats.count, &cpu_average );
    142       (*print)( context,
    143         "%" PRId32 "."  NANOSECONDS_FMT "/"        /* min cpu time */
    144         "%" PRId32 "."  NANOSECONDS_FMT "/"        /* max cpu time */
    145         "%" PRId32 "."  NANOSECONDS_FMT " ",       /* avg cpu time */
    146         _Timespec_Get_seconds( min_cpu ),
    147           _Timespec_Get_nanoseconds( min_cpu ) / NANOSECONDS_DIVIDER,
    148         _Timespec_Get_seconds( max_cpu ),
    149           _Timespec_Get_nanoseconds( max_cpu ) / NANOSECONDS_DIVIDER,
    150         _Timespec_Get_seconds( &cpu_average ),
    151           _Timespec_Get_nanoseconds( &cpu_average ) / NANOSECONDS_DIVIDER
    152        );
    153     #else
    154       uint32_t ival_cpu, fval_cpu;
    155 
    156       ival_cpu = the_stats.total_cpu_time * 100 / the_stats.count;
    157       fval_cpu = ival_cpu % 100;
    158       ival_cpu /= 100;
    159 
    160       (*print)( context,
    161         "%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 " ",
    162         the_stats.min_cpu_time, the_stats.max_cpu_time, ival_cpu, fval_cpu
    163       );
    164     #endif
    165     }
    166 
    167     /*
    168      *  print wall time part of statistics
    169      */
    170     {
    171     #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    172       struct timespec  wall_average;
    173       struct timespec *min_wall = &the_stats.min_wall_time;
    174       struct timespec *max_wall = &the_stats.max_wall_time;
    175       struct timespec *total_wall = &the_stats.total_wall_time;
    176 
    177       _Timespec_Divide_by_integer(total_wall, the_stats.count, &wall_average);
    178       (*print)( context,
    179         "%" PRId32 "." NANOSECONDS_FMT "/"        /* min wall time */
    180         "%" PRId32 "." NANOSECONDS_FMT "/"        /* max wall time */
    181         "%" PRId32 "." NANOSECONDS_FMT "\n",      /* avg wall time */
    182         _Timespec_Get_seconds( min_wall ),
    183           _Timespec_Get_nanoseconds( min_wall ) / NANOSECONDS_DIVIDER,
    184         _Timespec_Get_seconds( max_wall ),
    185           _Timespec_Get_nanoseconds( max_wall ) / NANOSECONDS_DIVIDER,
    186         _Timespec_Get_seconds( &wall_average ),
    187           _Timespec_Get_nanoseconds( &wall_average ) / NANOSECONDS_DIVIDER
    188       );
    189     #else
    190       uint32_t  ival_wall, fval_wall;
    191 
    192       ival_wall = the_stats.total_wall_time * 100 / the_stats.count;
    193       fval_wall = ival_wall % 100;
    194       ival_wall /= 100;
    195       (*print)( context,
    196         "%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 "\n",
    197         the_stats.min_wall_time, the_stats.max_wall_time, ival_wall, fval_wall
    198       );
    199     #endif
    200     }
    201   }
     41  rtems_periodic_report_statistics_with_plugin( context, print );
    20242}
    20343
    20444void rtems_rate_monotonic_report_statistics( void )
    20545{
    206   rtems_rate_monotonic_report_statistics_with_plugin( NULL, printk_plugin );
     46  rtems_periodic_report_statistics_with_plugin( NULL, printk_plugin );
    20747}
  • cpukit/rtems/src/ratemonresetall.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemonresetall.c,v
    retrieving revision 1.2
    diff -u -p -r1.2 ratemonresetall.c
     
    1919#include <rtems/rtems/status.h>
    2020#include <rtems/rtems/support.h>
    2121#include <rtems/score/object.h>
     22#include <rtems/rtems/periodic.h>
    2223#include <rtems/rtems/ratemon.h>
    2324#include <rtems/score/thread.h>
    2425
     
    2728 */
    2829void rtems_rate_monotonic_reset_all_statistics( void )
    2930{
    30   Objects_Id        id;
    31   rtems_status_code status;
    32 
    33    /*
    34     *  Prevent allocation or deallocation of any of the periods while
    35     *  we are cycling.  Also this is an optimization which ensures that
    36     *  we only disable/enable once.  The call to
    37     *  rtems_rate_monotonic_reset_statistics will be in a nested dispatch
    38     *  disabled critical section.
    39     */
    40   _Thread_Disable_dispatch();
    41 
    42     /*
    43      * Cycle through all possible ids and try to reset each one.  If it
    44      * is a period that is inactive, we just get an error back.  No big deal.
    45      */
    46     for ( id=_Rate_monotonic_Information.minimum_id ;
    47           id <= _Rate_monotonic_Information.maximum_id ;
    48           id++ ) {
    49       status = rtems_rate_monotonic_reset_statistics( id );
    50     }
    51 
    52   /*
    53    *  Done so exit thread dispatching disabled critical section.
    54    */
    55   _Thread_Enable_dispatch();
     31  rtems_periodic_reset_all_statistics();
    5632}
  • cpukit/rtems/src/ratemonresetstatistics.c

    RCS file: /usr1/CVS/rtems/cpukit/rtems/src/ratemonresetstatistics.c,v
    retrieving revision 1.4
    diff -u -p -r1.4 ratemonresetstatistics.c
     
    2020#include <rtems/rtems/support.h>
    2121#include <rtems/score/isr.h>
    2222#include <rtems/score/object.h>
     23#include <rtems/rtems/periodic.h>
    2324#include <rtems/rtems/ratemon.h>
    2425#include <rtems/score/thread.h>
    2526
    rtems_status_code rtems_rate_monotonic_r 
    4344  rtems_id id
    4445)
    4546{
    46   Objects_Locations              location;
    47   Rate_monotonic_Control        *the_period;
    48 
    49   the_period = _Rate_monotonic_Get( id, &location );
    50   switch ( location ) {
    51 
    52     case OBJECTS_LOCAL:
    53       _Rate_monotonic_Reset_statistics( the_period );
    54       _Thread_Enable_dispatch();
    55       return RTEMS_SUCCESSFUL;
    56 
    57 #if defined(RTEMS_MULTIPROCESSING)
    58     case OBJECTS_REMOTE:            /* should never return this */
    59 #endif
    60     case OBJECTS_ERROR:
    61       break;
    62   }
    63 
    64   return RTEMS_INVALID_ID;
     47  return rtems_periodic_reset_statistics( id );
    6548}
  • cpukit/score/Makefile.am

    RCS file: /usr1/CVS/rtems/cpukit/score/Makefile.am,v
    retrieving revision 1.87
    diff -u -p -r1.87 Makefile.am
    include_rtems_score_HEADERS = include/rt 
    2525    include/rtems/score/heap.h include/rtems/score/protectedheap.h \
    2626    include/rtems/score/interr.h include/rtems/score/isr.h \
    2727    include/rtems/score/object.h include/rtems/score/percpu.h \
     28    include/rtems/score/periodic.h \
    2829    include/rtems/score/priority.h include/rtems/score/prioritybitmap.h \
    2930    include/rtems/score/stack.h include/rtems/score/states.h \
    3031    include/rtems/score/sysstate.h include/rtems/score/thread.h \
    include_rtems_score_HEADERS += inline/rt 
    5354    inline/rtems/score/coremsg.inl inline/rtems/score/coremutex.inl \
    5455    inline/rtems/score/coresem.inl inline/rtems/score/heap.inl \
    5556    inline/rtems/score/isr.inl inline/rtems/score/object.inl \
     57    inline/rtems/score/periodic.inl \
    5658    inline/rtems/score/priority.inl inline/rtems/score/prioritybitmap.inl \
    5759    inline/rtems/score/stack.inl inline/rtems/score/states.inl \
    5860    inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \
    libscore_a_SOURCES += src/objectallocate 
    137139    src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \
    138140    src/objectnamespaceremove.c
    139141
     142## PERIODIC_C_FILES
     143libscore_a_SOURCES += src/periodic.c \
     144    src/periodicgetstatus.c src/periodicstatistics.c src/periodictimeout.c
     145
    140146## PROTECTED_HEAP_C_FILES
    141147libscore_a_SOURCES += src/pheapallocate.c \
    142148    src/pheapextend.c src/pheapfree.c src/pheapgetsize.c \
  • cpukit/score/preinstall.am

    RCS file: /usr1/CVS/rtems/cpukit/score/preinstall.am,v
    retrieving revision 1.24
    diff -u -p -r1.24 preinstall.am
    $(PROJECT_INCLUDE)/rtems/score/percpu.h: 
    103103        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/percpu.h
    104104PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/percpu.h
    105105
     106$(PROJECT_INCLUDE)/rtems/score/periodic.h: include/rtems/score/periodic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     107        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/periodic.h
     108PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/periodic.h
     109
    106110$(PROJECT_INCLUDE)/rtems/score/priority.h: include/rtems/score/priority.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    107111        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/priority.h
    108112PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.h
    $(PROJECT_INCLUDE)/rtems/score/object.in 
    237241        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/object.inl
    238242PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/object.inl
    239243
     244$(PROJECT_INCLUDE)/rtems/score/periodic.inl: inline/rtems/score/periodic.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     245        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/periodic.inl
     246PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/periodic.inl
     247
    240248$(PROJECT_INCLUDE)/rtems/score/priority.inl: inline/rtems/score/priority.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    241249        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/priority.inl
    242250PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.inl
  • testsuites/sptests/sp69/init.c

    RCS file: /usr1/CVS/rtems/testsuites/sptests/sp69/init.c,v
    retrieving revision 1.3
    diff -u -p -r1.3 init.c
    rtems_task Init( 
    4747
    4848  /* Check status values. */
    4949  rtems_test_assert( period_status.owner == rtems_task_self() );
    50   rtems_test_assert( period_status.state == RATE_MONOTONIC_INACTIVE );
     50  rtems_test_assert( period_status.state == PERIODIC_INACTIVE );
    5151  #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
    5252    rtems_test_assert( period_status.since_last_period.tv_sec == 0 );
    5353    rtems_test_assert( period_status.since_last_period.tv_nsec == 0 );
  • testsuites/sptests/spintrcritical08/init.c

    RCS file: /usr1/CVS/rtems/testsuites/sptests/spintrcritical08/init.c,v
    retrieving revision 1.4
    diff -u -p -r1.4 init.c
    rtems_id Main_task; 
    1717rtems_id Period;
    1818volatile bool case_hit;
    1919
    20 rtems_rate_monotonic_period_states getState(void)
     20rtems_periodic_period_states getState(void)
    2121{
    2222  Objects_Locations       location;
    23   Rate_monotonic_Control *period;
     23  Periodic_Control      *period;
    2424
    25   period = (Rate_monotonic_Control *)_Objects_Get(
    26     &_Rate_monotonic_Information, Period, &location );
     25  period = (Periodic_Control *)_Objects_Get(
     26    &_Periodic_Information, Period, &location
     27  );
    2728  if ( location != OBJECTS_LOCAL ) {
    2829    puts( "Bad object lookup" );
    2930    rtems_test_exit(0);
    rtems_timer_service_routine test_release 
    3839  void     *arg
    3940)
    4041{
    41   if ( getState() == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING )
     42  if ( getState() == PERIODIC_EXPIRED_WHILE_BLOCKING )
    4243    case_hit = true;
    4344}
    4445
    rtems_task Init( 
    5354
    5455  puts( "Init - Trying to generate period ending while blocking" );
    5556
    56   puts( "Init - rtems_rate_monotonic_create - OK" );
    57   sc = rtems_rate_monotonic_create(
     57  puts( "Init - rtems_periodic_create - OK" );
     58  sc = rtems_periodic_create(
    5859    rtems_build_name( 'P', 'E', 'R', '1' ),
    5960    &Period
    6061  );
    61   directive_failed( sc, "rtems_rate_monotonic_create" );
     62  directive_failed( sc, "rtems_periodic_create" );
    6263
    6364  Main_task = rtems_task_self();
    6465
    rtems_task Init( 
    7071    if ( interrupt_critical_section_test_support_delay() )
    7172      resets++;
    7273
    73     sc = rtems_rate_monotonic_period( Period, 1 );
     74    sc = rtems_periodic_period( Period, 1 );
    7475    if ( sc == RTEMS_TIMEOUT )
    7576      continue;
    76     directive_failed( sc, "rtems_monotonic_period");
     77    directive_failed( sc, "rtems_periodic_period");
    7778  }
    7879
    7980  if ( case_hit ) {
  • testsuites/sptests/spsize/size.c

    RCS file: /usr1/CVS/rtems/testsuites/sptests/spsize/size.c,v
    retrieving revision 1.67
    diff -u -p -r1.67 size.c
     
    3333#endif
    3434#include <rtems/rtems/part.h>
    3535#include <rtems/score/priority.h>
    36 #include <rtems/rtems/ratemon.h>
     36#include <rtems/score/periodic.h>
     37#include <rtems/rtems/periodic.h>
    3738#include <rtems/rtems/region.h>
    3839#include <rtems/rtems/sem.h>
    3940#include <rtems/rtems/signal.h>
    void print_formula(void); 
    8182#define PER_PART      \
    8283     (long) (sizeof (Partition_Control) + NAME_PTR_SIZE)
    8384#define PER_PERIOD      \
    84      (long) (sizeof (Rate_monotonic_Control) + NAME_PTR_SIZE)
     85     (long) (sizeof (Periodic_Control) + NAME_PTR_SIZE)
    8586#define PER_PORT      \
    8687     (long) (sizeof (Dual_ported_memory_Control) + NAME_PTR_SIZE)
    8788#define PER_EXTENSION     \
    uninitialized = 
    311312
    312313/*percpu.h*/    (sizeof _Per_CPU_Information)             +
    313314
     315/*periodic.h*/  (sizeof _Periodic_Information)            +
     316
    314317/*priority.h*/  (sizeof _Priority_Major_bit_map)          +
    315318                (sizeof _Priority_Bit_map)                +
    316319
    317 /*ratemon.h*/   (sizeof _Rate_monotonic_Information)      +
    318 
    319320/*region.h*/    (sizeof _Region_Information)              +
    320321
    321322#if defined(RTEMS_MULTIPROCESSING)