source: rtems/cpukit/rtems/include/rtems/rtems/ratemon.h @ 067a96a

4.104.114.95
Last change on this file since 067a96a was 067a96a, checked in by Joel Sherrill <joel.sherrill@…>, on 04/18/08 at 15:02:20

2008-04-18 Joel Sherrill <joel.sherrill@…>

  • rtems/include/rtems.h, rtems/include/rtems/rtems/asr.h, rtems/include/rtems/rtems/attr.h, rtems/include/rtems/rtems/barrier.h, rtems/include/rtems/rtems/barriermp.h, rtems/include/rtems/rtems/cache.h, rtems/include/rtems/rtems/clock.h, rtems/include/rtems/rtems/config.h, rtems/include/rtems/rtems/dpmem.h, rtems/include/rtems/rtems/event.h, rtems/include/rtems/rtems/eventmp.h, rtems/include/rtems/rtems/eventset.h, rtems/include/rtems/rtems/intr.h, rtems/include/rtems/rtems/message.h, rtems/include/rtems/rtems/modes.h, rtems/include/rtems/rtems/mp.h, rtems/include/rtems/rtems/msgmp.h, rtems/include/rtems/rtems/object.h, rtems/include/rtems/rtems/options.h, rtems/include/rtems/rtems/part.h, rtems/include/rtems/rtems/partmp.h, rtems/include/rtems/rtems/ratemon.h, rtems/include/rtems/rtems/region.h, rtems/include/rtems/rtems/regionmp.h, rtems/include/rtems/rtems/rtemsapi.h, rtems/include/rtems/rtems/sem.h, rtems/include/rtems/rtems/semmp.h, rtems/include/rtems/rtems/signal.h, rtems/include/rtems/rtems/signalmp.h, rtems/include/rtems/rtems/status.h, rtems/include/rtems/rtems/support.h, rtems/include/rtems/rtems/taskmp.h, rtems/include/rtems/rtems/tasks.h, rtems/include/rtems/rtems/timer.h, rtems/include/rtems/rtems/types.h, rtems/inline/rtems/rtems/asr.inl, rtems/inline/rtems/rtems/attr.inl, rtems/inline/rtems/rtems/barrier.inl, rtems/inline/rtems/rtems/dpmem.inl, rtems/inline/rtems/rtems/event.inl, rtems/inline/rtems/rtems/eventset.inl, rtems/inline/rtems/rtems/message.inl, rtems/inline/rtems/rtems/modes.inl, rtems/inline/rtems/rtems/options.inl, rtems/inline/rtems/rtems/part.inl, rtems/inline/rtems/rtems/ratemon.inl, rtems/inline/rtems/rtems/region.inl, rtems/inline/rtems/rtems/sem.inl, rtems/inline/rtems/rtems/status.inl, rtems/inline/rtems/rtems/support.inl, rtems/inline/rtems/rtems/tasks.inl, rtems/inline/rtems/rtems/timer.inl: Initial conversion of Classic API header files to Doxygen.
  • rtems/Doxyfile: New file.
  • Property mode set to 100644
File size: 10.0 KB
Line 
1/**
2 * @file rtems/rtems/ratemon.h
3 *
4 *  This include file contains all the constants, structures, and
5 *  prototypes associated with the Rate Monotonic Manager.  This manager
6 *  provides facilities to implement tasks which execute in a periodic fashion.
7 *
8 *  Directives provided are:
9 *
10 *     - create a rate monotonic timer
11 *     - cancel a period
12 *     - delete a rate monotonic timer
13 *     - conclude current and start the next period
14 *     - obtain status information on a period
15 */
16
17/*  COPYRIGHT (c) 1989-2007.
18 *  On-Line Applications Research Corporation (OAR).
19 *
20 *  The license and distribution terms for this file may be
21 *  found in the file LICENSE in this distribution or at
22 *  http://www.rtems.com/license/LICENSE.
23 *
24 *  $Id$
25 */
26
27#ifndef _RTEMS_RTEMS_RATEMON_H
28#define _RTEMS_RTEMS_RATEMON_H
29
30#ifndef RTEMS_RATEMON_EXTERN
31#define RTEMS_RATEMON_EXTERN extern
32#endif
33
34#include <rtems/bspIo.h>
35
36/**
37 *  @defgroup ClassicRateMon Classic API Rate Monotonic
38 *
39 *  This encapsulates functionality which XXX
40 */
41/**@{*/
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47/*
48 *  The user can define this at configure time and go back to ticks
49 *  resolution.
50 */
51#ifndef __RTEMS_USE_TICKS_RATE_MONOTONIC_STATISTICS__
52  /**
53   *  Enable the nanosecond accurate statistics
54   *
55   *  When not defined, the older style tick accurate granularity
56   *  is used.
57   */
58  #define RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
59#endif
60
61#include <rtems/score/object.h>
62#include <rtems/score/thread.h>
63#include <rtems/score/watchdog.h>
64#include <rtems/rtems/status.h>
65#include <rtems/rtems/support.h>
66
67#include <string.h>
68
69/**
70 *  The following enumerated type defines the states in which a
71 *  period may be.
72 */
73typedef enum {
74  RATE_MONOTONIC_INACTIVE,               /* off chain, never initialized */
75  RATE_MONOTONIC_OWNER_IS_BLOCKING,      /* on chain, owner is blocking on it */
76  RATE_MONOTONIC_ACTIVE,                 /* on chain, running continuously */
77  RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING, /* on chain, expired while owner was */
78                                         /*   was blocking on it */
79  RATE_MONOTONIC_EXPIRED                 /* off chain, will be reset by next */
80                                         /*   rtems_rate_monotonic_period */
81}   rtems_rate_monotonic_period_states;
82
83/**
84 *  The following constant is the interval passed to the rate_monontonic_period
85 *  directive to obtain status information.
86 */
87#define RTEMS_PERIOD_STATUS       WATCHDOG_NO_TIMEOUT
88
89/**
90 *  The following defines the statistics kept on each period instance.
91 */
92typedef struct {
93  uint32_t     count;
94  uint32_t     missed_count;
95  #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
96    struct timespec min_cpu_time;
97    struct timespec max_cpu_time;
98    struct timespec total_cpu_time;
99  #else
100    uint32_t  min_cpu_time;
101    uint32_t  max_cpu_time;
102    uint32_t  total_cpu_time;
103  #endif
104  #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
105    struct timespec min_wall_time;
106    struct timespec max_wall_time;
107    struct timespec total_wall_time;
108  #else
109    uint32_t  min_wall_time;
110    uint32_t  max_wall_time;
111    uint32_t  total_wall_time;
112  #endif
113}  rtems_rate_monotonic_period_statistics;
114
115/**
116 *  The following defines the period status structure.
117 */
118typedef struct {
119  Objects_Id                          owner;
120  rtems_rate_monotonic_period_states  state;
121  #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
122    struct timespec                   since_last_period;
123  #else
124    uint32_t                          ticks_since_last_period;
125  #endif
126  #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
127    struct timespec                   executed_since_last_period;
128  #else
129    uint32_t                          ticks_executed_since_last_period;
130  #endif
131}  rtems_rate_monotonic_period_status;
132
133/**
134 *  The following structure defines the control block used to manage
135 *  each period.
136 */
137typedef struct {
138  Objects_Control                         Object;
139  Watchdog_Control                        Timer;
140  rtems_rate_monotonic_period_states      state;
141  #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
142    struct timespec                       owner_executed_at_period;
143  #else
144    uint32_t                              owner_ticks_executed_at_period;
145  #endif
146  #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
147    struct timespec                       time_at_period;
148  #else
149    uint32_t                              time_at_period;
150  #endif
151  uint32_t                                next_length;
152  Thread_Control                         *owner;
153  rtems_rate_monotonic_period_statistics  Statistics;
154}   Rate_monotonic_Control;
155
156RTEMS_RATEMON_EXTERN Objects_Information _Rate_monotonic_Information;
157
158/**
159 *  _Rate_monotonic_Manager_initialization
160 *
161 *  This routine performs the initialization necessary for this manager.
162 */
163void _Rate_monotonic_Manager_initialization(
164  uint32_t   maximum_periods
165);
166
167/**
168 *  @brief rtems_rate_monotonic_create
169 *
170 *  This routine implements the rate_monotonic_create directive.  The
171 *  period will have the name name.  It returns the id of the
172 *  created period in ID.
173 */
174rtems_status_code rtems_rate_monotonic_create(
175  rtems_name    name,
176  Objects_Id   *id
177);
178
179/**
180 *  @brief rtems_rate_monotonic_ident
181 *
182 *  This routine implements the rtems_rate_monotonic_ident directive.
183 *  This directive returns the period ID associated with name.
184 *  If more than one period is named name, then the period
185 *  to which the ID belongs is arbitrary.
186 */
187rtems_status_code rtems_rate_monotonic_ident(
188  rtems_name    name,
189  Objects_Id   *id
190);
191
192/**
193 *  @brief rtems_rate_monotonic_cancel
194 *
195 *  This routine implements the rtems_rate_monotonic_cancel directive.  This
196 *  directive stops the period associated with ID from continuing to
197 *  run.
198 */
199rtems_status_code rtems_rate_monotonic_cancel(
200  Objects_Id id
201);
202
203/**
204 *  @brief rtems_rate_monotonic_delete
205 *
206 *  This routine implements the rtems_rate_monotonic_delete directive.  The
207 *  period indicated by ID is deleted.
208 */
209rtems_status_code rtems_rate_monotonic_delete(
210  Objects_Id id
211);
212
213/**
214 *  @brief rtems_rate_monotonic_get_status
215 *
216 *  This routine implements the rtems_rate_monotonic_get_status directive.
217 *  Information about the period indicated by ID is returned.
218 *
219 */
220rtems_status_code rtems_rate_monotonic_get_status(
221  Objects_Id                           id,
222  rtems_rate_monotonic_period_status  *status
223);
224
225/**
226 *  @brief rtems_rate_monotonic_get_statistics
227 *
228 *  This routine implements the rtems_rate_monotonic_get_statistics directive.
229 *  Statistics gathered from the use of this period are returned.
230 */
231rtems_status_code rtems_rate_monotonic_get_statistics(
232  Objects_Id                              id,
233  rtems_rate_monotonic_period_statistics *statistics
234);
235
236/**
237 *  @brief rtems_rate_monotonic_reset_statistics
238 *
239 *  This directive allows a thread to reset the statistics information
240 *  on a specific period instance.
241 */
242rtems_status_code rtems_rate_monotonic_reset_statistics(
243  Objects_Id                               id
244);
245
246/**
247 *  @brief rtems_rate_monotonic_reset_all_statistics
248 *
249 *  This directive allows a thread to reset the statistics information
250 *  on ALL period instances.
251 */
252void rtems_rate_monotonic_reset_all_statistics( void );
253
254/**
255 *  @brief rtems_rate_monotonic_report_statistics
256 *
257 *  This directive allows a thread to print the statistics information
258 *  on ALL period instances which have non-zero counts using printk.
259 */
260void rtems_rate_monotonic_report_statistics_with_plugin(
261  void                  *context,
262  rtems_printk_plugin_t  print
263);
264
265/**
266 *  @brief rtems_rate_monotonic_report_statistics
267 *
268 *  This directive allows a thread to print the statistics information
269 *  on ALL period instances which have non-zero counts using printk.
270 */
271void rtems_rate_monotonic_report_statistics( void );
272
273/**
274 *  @brief rtems_rate_monotonic_period
275 *
276 *  This routine implements the rtems_rate_monotonic_period directive.  When
277 *  length is non-zero, this directive initiates the period associated with
278 *  ID from continuing for a period of length.  If length is zero, then
279 *  result is set to indicate the current state of the period.
280 */
281rtems_status_code rtems_rate_monotonic_period(
282  Objects_Id      id,
283  rtems_interval  length
284);
285
286/**
287 *  @brief _Rate_monotonic_Timeout
288 *
289 *  This routine is invoked when the period represented
290 *  by ID expires.  If the task which owns this period is blocked
291 *  waiting for the period to expire, then it is readied and the
292 *  period is restarted.  If the owning task is not waiting for the
293 *  period to expire, then the period is placed in the EXPIRED
294 *  state and not restarted.
295 */
296void _Rate_monotonic_Timeout(
297  Objects_Id  id,
298  void       *ignored
299);
300
301/**
302 *  @brief _Rate_monotonic_Reset_statistics
303 *
304 *  This method resets the statistics information for a period instance.
305 */
306#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
307  #define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
308     do { \
309        /* set the minimums to a large value */ \
310        (_the_period)->Statistics.min_wall_time.tv_sec = 0x7fffffff; \
311        (_the_period)->Statistics.min_wall_time.tv_nsec = 0x7fffffff; \
312     } while (0)
313#else
314  #define _Rate_monotonic_Reset_wall_time_statistics( _the_period )
315#endif
316
317#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
318  #define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
319     do { \
320        /* set the minimums to a large value */ \
321        (_the_period)->Statistics.min_cpu_time.tv_sec = 0x7fffffff; \
322        (_the_period)->Statistics.min_cpu_time.tv_nsec = 0x7fffffff; \
323     } while (0)
324#else
325  #define _Rate_monotonic_Reset_cpu_use_statistics( _the_period )
326#endif
327
328#define _Rate_monotonic_Reset_statistics( _the_period ) \
329  do { \
330    memset( \
331      &(_the_period)->Statistics, \
332      0, \
333      sizeof( rtems_rate_monotonic_period_statistics ) \
334    ); \
335    _Rate_monotonic_Reset_cpu_use_statistics( _the_period ); \
336    _Rate_monotonic_Reset_wall_time_statistics( _the_period ); \
337  } while (0)
338
339#ifndef __RTEMS_APPLICATION__
340#include <rtems/rtems/ratemon.inl>
341#endif
342
343#ifdef __cplusplus
344}
345#endif
346
347/**@}*/
348
349#endif
350/* end of include file */
Note: See TracBrowser for help on using the repository browser.