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

Last change on this file was bcef89f2, checked in by Sebastian Huber <sebastian.huber@…>, on 05/19/23 at 06:18:25

Update company name

The embedded brains GmbH & Co. KG is the legal successor of embedded
brains GmbH.

  • Property mode set to 100644
File size: 22.1 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSImplClassicRateMonotonic
7 *
8 * @brief This header file defines the Rate-Monotonic Manager API.
9 */
10
11/*
12 * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG
13 * Copyright (C) 2017 Kuan-Hsun Chen
14 * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 *    notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 *    notice, this list of conditions and the following disclaimer in the
23 *    documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38/*
39 * This file is part of the RTEMS quality process and was automatically
40 * generated.  If you find something that needs to be fixed or
41 * worded better please post a report or patch to an RTEMS mailing list
42 * or raise a bug report:
43 *
44 * https://www.rtems.org/bugs.html
45 *
46 * For information on updating and regenerating please refer to the How-To
47 * section in the Software Requirements Engineering chapter of the
48 * RTEMS Software Engineering manual.  The manual is provided as a part of
49 * a release.  For development sources please refer to the online
50 * documentation at:
51 *
52 * https://docs.rtems.org
53 */
54
55/* Generated from spec:/rtems/ratemon/if/header */
56
57#ifndef _RTEMS_RTEMS_RATEMON_H
58#define _RTEMS_RTEMS_RATEMON_H
59
60#include <stdint.h>
61#include <sys/_timespec.h>
62#include <rtems/rtems/status.h>
63#include <rtems/rtems/types.h>
64#include <rtems/score/watchdogticks.h>
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
70/* Generated from spec:/rtems/ratemon/if/group */
71
72/**
73 * @defgroup RTEMSAPIClassicRatemon Rate-Monotonic Manager
74 *
75 * @ingroup RTEMSAPIClassic
76 *
77 * @brief The Rate-Monotonic Manager provides facilities to implement tasks
78 *   which execute in a periodic fashion.  Critically, it also gathers
79 *   information about the execution of those periods and can provide important
80 *   statistics to the user which can be used to analyze and tune the
81 *   application.
82 */
83
84/* Generated from spec:/rtems/ratemon/if/period-states */
85
86/**
87 * @ingroup RTEMSAPIClassicRatemon
88 *
89 * @brief This enumeration defines the states in which a period may be.
90 */
91typedef enum {
92  /**
93   * @brief This status indicates the period is off the watchdog chain, and has
94   *   never been initialized.
95   */
96  RATE_MONOTONIC_INACTIVE,
97
98  /**
99   * @brief This status indicates the period is on the watchdog chain, and
100   *   running.  The owner may be executing or blocked waiting on another object.
101   */
102  RATE_MONOTONIC_ACTIVE,
103
104  /**
105   * @brief This status indicates the period is off the watchdog chain, and has
106   *   expired. The owner may still execute and has taken too much time to
107   *   complete this iteration of the period.
108   */
109  RATE_MONOTONIC_EXPIRED
110} rtems_rate_monotonic_period_states;
111
112/* Generated from spec:/rtems/ratemon/if/period-statistics */
113
114/**
115 * @ingroup RTEMSAPIClassicRatemon
116 *
117 * @brief This structure provides the statistics of a period.
118 */
119typedef struct {
120  /**
121   * @brief This member contains the number of periods executed.
122   */
123  uint32_t count;
124
125  /**
126   * @brief This member contains the number of periods missed.
127   */
128  uint32_t missed_count;
129
130  /**
131   * @brief This member contains the least amount of processor time used in a
132   *   period.
133   */
134  struct timespec min_cpu_time;
135
136  /**
137   * @brief This member contains the highest amount of processor time used in a
138   *   period.
139   */
140  struct timespec max_cpu_time;
141
142  /**
143   * @brief This member contains the total amount of processor time used in a
144   *   period.
145   */
146  struct timespec total_cpu_time;
147
148  /**
149   * @brief This member contains the least amount of CLOCK_MONOTONIC time used in
150   *   a period.
151   */
152  struct timespec min_wall_time;
153
154  /**
155   * @brief This member contains the highest amount of CLOCK_MONOTONIC time used
156   *   in a period.
157   */
158  struct timespec max_wall_time;
159
160  /**
161   * @brief This member contains the total amount of CLOCK_MONOTONIC time used in
162   *   a period.
163   */
164  struct timespec total_wall_time;
165} rtems_rate_monotonic_period_statistics;
166
167/* Generated from spec:/rtems/ratemon/if/period-status */
168
169/**
170 * @ingroup RTEMSAPIClassicRatemon
171 *
172 * @brief This structure provides the detailed status of a period.
173 */
174typedef struct {
175  /**
176   * @brief This member contains the identifier of the owner task of the period.
177   */
178  rtems_id owner;
179
180  /**
181   * @brief This member contains the state of the period.
182   */
183  rtems_rate_monotonic_period_states state;
184
185  /**
186   * @brief This member contains the time elapsed since the last successful
187   *   invocation rtems_rate_monotonic_period() using CLOCK_MONOTONIC.
188   *
189   * If the period is expired or has not been initiated, then this value has no
190   * meaning.
191   */
192  struct timespec since_last_period;
193
194  /**
195   * @brief This member contains the processor time consumed by the owner task
196   *   since the last successful invocation rtems_rate_monotonic_period().
197   *
198   * If the period is expired or has not been initiated, then this value has no
199   * meaning.
200   */
201  struct timespec executed_since_last_period;
202
203  /**
204   * @brief This member contains the count of jobs which are not released yet.
205   */
206  uint32_t postponed_jobs_count;
207} rtems_rate_monotonic_period_status;
208
209/* Generated from spec:/rtems/ratemon/if/period-status-define */
210
211/**
212 * @ingroup RTEMSAPIClassicRatemon
213 *
214 * @brief This constant is the interval passed to the
215 *   rtems_rate_monotonic_period() directive to obtain status information.
216 */
217#define RTEMS_PERIOD_STATUS WATCHDOG_NO_TIMEOUT
218
219/* Generated from spec:/rtems/ratemon/if/printer */
220
221/* Forward declaration */
222struct rtems_printer;
223
224/* Generated from spec:/rtems/ratemon/if/create */
225
226/**
227 * @ingroup RTEMSAPIClassicRatemon
228 *
229 * @brief Creates a period.
230 *
231 * @param name is the object name of the period.
232 *
233 * @param[out] id is the pointer to an ::rtems_id object.  When the directive
234 *   call is successful, the identifier of the created period will be stored in
235 *   this object.
236 *
237 * This directive creates a period which resides on the local node.  The period
238 * has the user-defined object name specified in ``name`` The assigned object
239 * identifier is returned in ``id``.  This identifier is used to access the
240 * period with other rate monotonic related directives.
241 *
242 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
243 *
244 * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was invalid.
245 *
246 * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a
247 *   period.  The number of periods available to the application is configured
248 *   through the @ref CONFIGURE_MAXIMUM_PERIODS application configuration
249 *   option.
250 *
251 * @par Notes
252 * @parblock
253 * The calling task is registered as the owner of the created period.  Some
254 * directives can be only used by this task for the created period.
255 *
256 * For control and maintenance of the period, RTEMS allocates a PCB from the
257 * local PCB free pool and initializes it.
258 * @endparblock
259 *
260 * @par Constraints
261 * @parblock
262 * The following constraints apply to this directive:
263 *
264 * * The directive may be called from within device driver initialization
265 *   context.
266 *
267 * * The directive may be called from within task context.
268 *
269 * * The directive may obtain and release the object allocator mutex.  This may
270 *   cause the calling task to be preempted.
271 *
272 * * The number of periods available to the application is configured through
273 *   the @ref CONFIGURE_MAXIMUM_PERIODS application configuration option.
274 *
275 * * Where the object class corresponding to the directive is configured to use
276 *   unlimited objects, the directive may allocate memory from the RTEMS
277 *   Workspace.
278 * @endparblock
279 */
280rtems_status_code rtems_rate_monotonic_create( rtems_name name, rtems_id *id );
281
282/* Generated from spec:/rtems/ratemon/if/ident */
283
284/**
285 * @ingroup RTEMSAPIClassicRatemon
286 *
287 * @brief Identifies a period by the object name.
288 *
289 * @param name is the object name to look up.
290 *
291 * @param[out] id is the pointer to an ::rtems_id object.  When the directive
292 *   call is successful, the object identifier of an object with the specified
293 *   name will be stored in this object.
294 *
295 * This directive obtains a period identifier associated with the period name
296 * specified in ``name``.
297 *
298 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
299 *
300 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
301 *
302 * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was 0.
303 *
304 * @retval ::RTEMS_INVALID_NAME There was no object with the specified name on
305 *   the local node.
306 *
307 * @par Notes
308 * @parblock
309 * If the period name is not unique, then the period identifier will match the
310 * first period with that name in the search order.  However, this period
311 * identifier is not guaranteed to correspond to the desired period.
312 *
313 * The objects are searched from lowest to the highest index.  Only the local
314 * node is searched.
315 *
316 * The period identifier is used with other rate monotonic related directives
317 * to access the period.
318 * @endparblock
319 *
320 * @par Constraints
321 * @parblock
322 * The following constraints apply to this directive:
323 *
324 * * The directive may be called from within any runtime context.
325 *
326 * * The directive will not cause the calling task to be preempted.
327 * @endparblock
328 */
329rtems_status_code rtems_rate_monotonic_ident( rtems_name name, rtems_id *id );
330
331/* Generated from spec:/rtems/ratemon/if/cancel */
332
333/**
334 * @ingroup RTEMSAPIClassicRatemon
335 *
336 * @brief Cancels the period.
337 *
338 * @param id is the rate monotonic period identifier.
339 *
340 * This directive cancels the rate monotonic period specified by ``id``.  This
341 * period may be reinitiated by the next invocation of
342 * rtems_rate_monotonic_period().
343 *
344 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
345 *
346 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
347 *   with the identifier specified by ``id``.
348 *
349 * @retval ::RTEMS_NOT_OWNER_OF_RESOURCE The rate monotonic period was not
350 *   created by the calling task.
351 *
352 * @par Constraints
353 * @parblock
354 * The following constraints apply to this directive:
355 *
356 * * The directive may be called from within task context.
357 *
358 * * The directive will not cause the calling task to be preempted.
359 *
360 * * The directive may be used exclusively by the task which created the
361 *   associated object.
362 * @endparblock
363 */
364rtems_status_code rtems_rate_monotonic_cancel( rtems_id id );
365
366/* Generated from spec:/rtems/ratemon/if/delete */
367
368/**
369 * @ingroup RTEMSAPIClassicRatemon
370 *
371 * @brief Deletes the period.
372 *
373 * @param id is the period identifier.
374 *
375 * This directive deletes the period specified by ``id``.  If the period is
376 * running, it is automatically canceled.
377 *
378 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
379 *
380 * @retval ::RTEMS_INVALID_ID There was no period associated with the
381 *   identifier specified by ``id``.
382 *
383 * @par Notes
384 * The PCB for the deleted period is reclaimed by RTEMS.
385 *
386 * @par Constraints
387 * @parblock
388 * The following constraints apply to this directive:
389 *
390 * * The directive may be called from within device driver initialization
391 *   context.
392 *
393 * * The directive may be called from within task context.
394 *
395 * * The directive may obtain and release the object allocator mutex.  This may
396 *   cause the calling task to be preempted.
397 *
398 * * The calling task does not have to be the task that created the object.
399 *   Any local task that knows the object identifier can delete the object.
400 *
401 * * Where the object class corresponding to the directive is configured to use
402 *   unlimited objects, the directive may free memory to the RTEMS Workspace.
403 * @endparblock
404 */
405rtems_status_code rtems_rate_monotonic_delete( rtems_id id );
406
407/* Generated from spec:/rtems/ratemon/if/period */
408
409/**
410 * @ingroup RTEMSAPIClassicRatemon
411 *
412 * @brief Concludes the current period and start the next period, or gets the
413 *   period status.
414 *
415 * @param id is the rate monotonic period identifier.
416 *
417 * @param length is the period length in clock ticks or #RTEMS_PERIOD_STATUS to
418 *   get the period status.
419 *
420 * This directive initiates the rate monotonic period specified by ``id``  with
421 * a length of period ticks specified by ``length``.  If the period is running,
422 * then the calling task will block for the remainder of the period before
423 * reinitiating the period with the specified period length.  If the period was
424 * not running (either expired or never initiated), the period is immediately
425 * initiated and the directive returns immediately.  If the period has expired,
426 * the postponed job will be released immediately and the following calls of
427 * this directive will release postponed jobs until there is no more deadline
428 * miss.
429 *
430 * If invoked with a period length of #RTEMS_PERIOD_STATUS ticks, the current
431 * state of the period will be returned.  The directive status indicates the
432 * current state of the period.  This does not alter the state or period length
433 * of the period.
434 *
435 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
436 *
437 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
438 *   with the identifier specified by ``id``.
439 *
440 * @retval ::RTEMS_NOT_OWNER_OF_RESOURCE The rate monotonic period was not
441 *   created by the calling task.
442 *
443 * @retval ::RTEMS_NOT_DEFINED The rate monotonic period has never been
444 *   initiated (only possible when the ``length`` parameter was equal to
445 *   #RTEMS_PERIOD_STATUS).
446 *
447 * @retval ::RTEMS_TIMEOUT The rate monotonic period has expired.
448 *
449 * @par Notes
450 * Resetting the processor usage time of tasks has no impact on the period
451 * status and statistics.
452 *
453 * @par Constraints
454 * @parblock
455 * The following constraints apply to this directive:
456 *
457 * * The directive may be called from within task context.
458 *
459 * * The directive may be used exclusively by the task which created the
460 *   associated object.
461 * @endparblock
462 */
463rtems_status_code rtems_rate_monotonic_period(
464  rtems_id       id,
465  rtems_interval length
466);
467
468/* Generated from spec:/rtems/ratemon/if/get-status */
469
470/**
471 * @ingroup RTEMSAPIClassicRatemon
472 *
473 * @brief Gets the detailed status of the period.
474 *
475 * @param id is the rate monotonic period identifier.
476 *
477 * @param[out] status is the pointer to an rtems_rate_monotonic_period_status
478 *   object.  When the directive call is successful, the detailed period status
479 *   will be stored in this object.
480 *
481 * This directive returns the detailed status of the rate monotonic period
482 * specified by ``id``.  The detailed status of the period will be returned in
483 * the members of the period status object referenced by ``status``:
484 *
485 * * The ``owner`` member is set to the identifier of the owner task of the
486 *   period.
487 *
488 * * The ``state`` member is set to the current state of the period.
489 *
490 * * The ``postponed_jobs_count`` member is set to the count of jobs which are
491 *   not released yet.
492 *
493 * * If the current state of the period is ::RATE_MONOTONIC_INACTIVE, the
494 *   ``since_last_period`` and ``executed_since_last_period`` members will be
495 *   set to zero.  Otherwise, both members will contain time information since
496 *   the last successful invocation of the rtems_rate_monotonic_period()
497 *   directive by the owner task.  More specifically, the ``since_last_period``
498 *   member will be set to the time elapsed since the last successful
499 *   invocation.  The ``executed_since_last_period`` member will be set to the
500 *   processor time consumed by the owner task since the last successful
501 *   invocation.
502 *
503 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
504 *
505 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
506 *   with the identifier specified by ``id``.
507 *
508 * @retval ::RTEMS_INVALID_ADDRESS The ``status`` parameter was NULL.
509 *
510 * @par Constraints
511 * @parblock
512 * The following constraints apply to this directive:
513 *
514 * * The directive may be called from within task context.
515 *
516 * * The directive may be called from within interrupt context.
517 *
518 * * The directive will not cause the calling task to be preempted.
519 * @endparblock
520 */
521rtems_status_code rtems_rate_monotonic_get_status(
522  rtems_id                            id,
523  rtems_rate_monotonic_period_status *status
524);
525
526/* Generated from spec:/rtems/ratemon/if/get-statistics */
527
528/**
529 * @ingroup RTEMSAPIClassicRatemon
530 *
531 * @brief Gets the statistics of the period.
532 *
533 * @param id is the rate monotonic period identifier.
534 *
535 * @param[out] status is the pointer to an
536 *   rtems_rate_monotonic_period_statistics object.  When the directive call is
537 *   successful, the period statistics will be stored in this object.
538 *
539 * This directive returns the statistics of the rate monotonic period specified
540 * by ``id``.  The statistics of the period will be returned in the members of
541 * the period statistics object referenced by ``status``:
542 *
543 * * The ``count`` member is set to the number of periods executed.
544 *
545 * * The ``missed_count`` member is set to the number of periods missed.
546 *
547 * * The ``min_cpu_time`` member is set to the least amount of processor time
548 *   used in the period.
549 *
550 * * The ``max_cpu_time`` member is set to the highest amount of processor time
551 *   used in the period.
552 *
553 * * The ``total_cpu_time`` member is set to the total amount of processor time
554 *   used in the period.
555 *
556 * * The ``min_wall_time`` member is set to the least amount of CLOCK_MONOTONIC
557 *   time used in the period.
558 *
559 * * The ``max_wall_time`` member is set to the highest amount of
560 *   CLOCK_MONOTONIC time used in the period.
561 *
562 * * The ``total_wall_time`` member is set to the total amount of
563 *   CLOCK_MONOTONIC time used in the period.
564 *
565 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
566 *
567 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
568 *   with the identifier specified by ``id``.
569 *
570 * @retval ::RTEMS_INVALID_ADDRESS The ``status`` parameter was NULL.
571 *
572 * @par Constraints
573 * @parblock
574 * The following constraints apply to this directive:
575 *
576 * * The directive may be called from within task context.
577 *
578 * * The directive may be called from within interrupt context.
579 *
580 * * The directive will not cause the calling task to be preempted.
581 * @endparblock
582 */
583rtems_status_code rtems_rate_monotonic_get_statistics(
584  rtems_id                                id,
585  rtems_rate_monotonic_period_statistics *status
586);
587
588/* Generated from spec:/rtems/ratemon/if/reset-statistics */
589
590/**
591 * @ingroup RTEMSAPIClassicRatemon
592 *
593 * @brief Resets the statistics of the period.
594 *
595 * @param id is the rate monotonic period identifier.
596 *
597 * This directive resets the statistics of the rate monotonic period specified
598 * by ``id``.
599 *
600 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
601 *
602 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
603 *   with the identifier specified by ``id``.
604 *
605 * @par Constraints
606 * @parblock
607 * The following constraints apply to this directive:
608 *
609 * * The directive may be called from within task context.
610 *
611 * * The directive may be called from within interrupt context.
612 *
613 * * The directive will not cause the calling task to be preempted.
614 * @endparblock
615 */
616rtems_status_code rtems_rate_monotonic_reset_statistics( rtems_id id );
617
618/* Generated from spec:/rtems/ratemon/if/reset-all-statistics */
619
620/**
621 * @ingroup RTEMSAPIClassicRatemon
622 *
623 * @brief Resets the statistics of all periods.
624 *
625 * This directive resets the statistics information associated with all rate
626 * monotonic period instances.
627 *
628 * @par Constraints
629 * @parblock
630 * The following constraints apply to this directive:
631 *
632 * * The directive may be called from within task context.
633 *
634 * * The directive may obtain and release the object allocator mutex.  This may
635 *   cause the calling task to be preempted.
636 * @endparblock
637 */
638void rtems_rate_monotonic_reset_all_statistics( void );
639
640/* Generated from spec:/rtems/ratemon/if/report-statistics */
641
642/**
643 * @ingroup RTEMSAPIClassicRatemon
644 *
645 * @brief Reports the period statistics using the printk() printer.
646 *
647 * This directive prints a report on all active periods which have executed at
648 * least one period using the printk() printer.
649 *
650 * @par Constraints
651 * @parblock
652 * The following constraints apply to this directive:
653 *
654 * * The directive may be called from within task context.
655 *
656 * * The directive may obtain and release the object allocator mutex.  This may
657 *   cause the calling task to be preempted.
658 * @endparblock
659 */
660void rtems_rate_monotonic_report_statistics( void );
661
662/* Generated from spec:/rtems/ratemon/if/report-statistics-with-plugin */
663
664/**
665 * @ingroup RTEMSAPIClassicRatemon
666 *
667 * @brief Reports the period statistics using the printer plugin.
668 *
669 * @param printer is the printer plugin to output the report.
670 *
671 * This directive prints a report on all active periods which have executed at
672 * least one period using the printer plugin specified by ``printer``.
673 *
674 * @par Constraints
675 * @parblock
676 * The following constraints apply to this directive:
677 *
678 * * The directive may be called from within task context.
679 *
680 * * The directive may obtain and release the object allocator mutex.  This may
681 *   cause the calling task to be preempted.
682 * @endparblock
683 */
684void rtems_rate_monotonic_report_statistics_with_plugin(
685  const struct rtems_printer *printer
686);
687
688#ifdef __cplusplus
689}
690#endif
691
692#endif /* _RTEMS_RTEMS_RATEMON_H */
Note: See TracBrowser for help on using the repository browser.