source: rtems/cpukit/rtems/include/rtems/rtems/ratemon.h @ f9293df

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

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

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