source: rtems/cpukit/include/rtems/rtems/ratemon.h @ 24922d0

Last change on this file since 24922d0 was 24922d0, checked in by Sebastian Huber <sebastian.huber@…>, on 10/25/21 at 06:15:37

rtems: rtems_rate_monotonic_get_status()

Mention that resetting the processor usage time of tasks has no impact
on the period status and statistics.

Remove no longer relevant RTEMS_NOT_DEFINED error status.

Update #4528.

  • 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 (http://www.embedded-brains.de)
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 #CONFIGURE_MAXIMUM_PERIODS application configuration option.
249 *
250 * @par Notes
251 * @parblock
252 * The calling task is registered as the owner of the created period.  Some
253 * directives can be only used by this task for the created period.
254 *
255 * For control and maintenance of the period, RTEMS allocates a PCB from the
256 * local PCB free pool and initializes it.
257 * @endparblock
258 *
259 * @par Constraints
260 * @parblock
261 * The following constraints apply to this directive:
262 *
263 * * The directive may be called from within device driver initialization
264 *   context.
265 *
266 * * The directive may be called from within task context.
267 *
268 * * The directive may obtain and release the object allocator mutex.  This may
269 *   cause the calling task to be preempted.
270 *
271 * * The number of periods available to the application is configured through
272 *   the #CONFIGURE_MAXIMUM_PERIODS application configuration option.
273 *
274 * * Where the object class corresponding to the directive is configured to use
275 *   unlimited objects, the directive may allocate memory from the RTEMS
276 *   Workspace.
277 * @endparblock
278 */
279rtems_status_code rtems_rate_monotonic_create( rtems_name name, rtems_id *id );
280
281/* Generated from spec:/rtems/ratemon/if/ident */
282
283/**
284 * @ingroup RTEMSAPIClassicRatemon
285 *
286 * @brief Identifies a period by the object name.
287 *
288 * @param name is the object name to look up.
289 *
290 * @param[out] id is the pointer to an ::rtems_id object.  When the directive
291 *   call is successful, the object identifier of an object with the specified
292 *   name will be stored in this object.
293 *
294 * This directive obtains a period identifier associated with the period name
295 * specified in ``name``.
296 *
297 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
298 *
299 * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL.
300 *
301 * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was 0.
302 *
303 * @retval ::RTEMS_INVALID_NAME There was no object with the specified name on
304 *   the local node.
305 *
306 * @par Notes
307 * @parblock
308 * If the period name is not unique, then the period identifier will match the
309 * first period with that name in the search order.  However, this period
310 * identifier is not guaranteed to correspond to the desired period.
311 *
312 * The objects are searched from lowest to the highest index.  Only the local
313 * node is searched.
314 *
315 * The period identifier is used with other rate monotonic related directives
316 * to access the period.
317 * @endparblock
318 *
319 * @par Constraints
320 * @parblock
321 * The following constraints apply to this directive:
322 *
323 * * The directive may be called from within any runtime context.
324 *
325 * * The directive will not cause the calling task to be preempted.
326 * @endparblock
327 */
328rtems_status_code rtems_rate_monotonic_ident( rtems_name name, rtems_id *id );
329
330/* Generated from spec:/rtems/ratemon/if/cancel */
331
332/**
333 * @ingroup RTEMSAPIClassicRatemon
334 *
335 * @brief Cancels the period.
336 *
337 * @param id is the rate monotonic period identifier.
338 *
339 * This directive cancels the rate monotonic period specified by ``id``.  This
340 * period may be reinitiated by the next invocation of
341 * rtems_rate_monotonic_period().
342 *
343 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
344 *
345 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
346 *   with the identifier specified by ``id``.
347 *
348 * @retval ::RTEMS_NOT_OWNER_OF_RESOURCE The rate monotonic period was not
349 *   created by the calling task.
350 *
351 * @par Constraints
352 * @parblock
353 * The following constraints apply to this directive:
354 *
355 * * The directive may be called from within task context.
356 *
357 * * The directive will not cause the calling task to be preempted.
358 *
359 * * The directive may be used exclusively by the task which created the
360 *   associated object.
361 * @endparblock
362 */
363rtems_status_code rtems_rate_monotonic_cancel( rtems_id id );
364
365/* Generated from spec:/rtems/ratemon/if/delete */
366
367/**
368 * @ingroup RTEMSAPIClassicRatemon
369 *
370 * @brief Deletes the period.
371 *
372 * @param id is the period identifier.
373 *
374 * This directive deletes the period specified by ``id``.  If the period is
375 * running, it is automatically canceled.
376 *
377 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
378 *
379 * @retval ::RTEMS_INVALID_ID There was no period associated with the
380 *   identifier specified by ``id``.
381 *
382 * @par Notes
383 * The PCB for the deleted period is reclaimed by RTEMS.
384 *
385 * @par Constraints
386 * @parblock
387 * The following constraints apply to this directive:
388 *
389 * * The directive may be called from within device driver initialization
390 *   context.
391 *
392 * * The directive may be called from within task context.
393 *
394 * * The directive may obtain and release the object allocator mutex.  This may
395 *   cause the calling task to be preempted.
396 *
397 * * The calling task does not have to be the task that created the object.
398 *   Any local task that knows the object identifier can delete the object.
399 *
400 * * Where the object class corresponding to the directive is configured to use
401 *   unlimited objects, the directive may free memory to the RTEMS Workspace.
402 * @endparblock
403 */
404rtems_status_code rtems_rate_monotonic_delete( rtems_id id );
405
406/* Generated from spec:/rtems/ratemon/if/period */
407
408/**
409 * @ingroup RTEMSAPIClassicRatemon
410 *
411 * @brief Concludes the current period and start the next period, or gets the
412 *   period status.
413 *
414 * @param id is the rate monotonic period identifier.
415 *
416 * @param length is the period length in clock ticks or #RTEMS_PERIOD_STATUS to
417 *   get the period status.
418 *
419 * This directive initiates the rate monotonic period specified by ``id``  with
420 * a length of period ticks specified by ``length``.  If the period is running,
421 * then the calling task will block for the remainder of the period before
422 * reinitiating the period with the specified period length.  If the period was
423 * not running (either expired or never initiated), the period is immediately
424 * initiated and the directive returns immediately.  If the period has expired,
425 * the postponed job will be released immediately and the following calls of
426 * this directive will release postponed jobs until there is no more deadline
427 * miss.
428 *
429 * If invoked with a period length of #RTEMS_PERIOD_STATUS ticks, the current
430 * state of the period will be returned.  The directive status indicates the
431 * current state of the period.  This does not alter the state or period length
432 * of the period.
433 *
434 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
435 *
436 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
437 *   with the identifier specified by ``id``.
438 *
439 * @retval ::RTEMS_NOT_OWNER_OF_RESOURCE The rate monotonic period was not
440 *   created by the calling task.
441 *
442 * @retval ::RTEMS_NOT_DEFINED The rate monotonic period has never been
443 *   initiated (only possible when the ``length`` parameter was equal to
444 *   #RTEMS_PERIOD_STATUS).
445 *
446 * @retval ::RTEMS_TIMEOUT The rate monotonic period has expired.
447 *
448 * @par Notes
449 * Resetting the processor usage time of tasks has no impact on the period
450 * status and statistics.
451 *
452 * @par Constraints
453 * @parblock
454 * The following constraints apply to this directive:
455 *
456 * * The directive may be called from within task context.
457 *
458 * * The directive may be used exclusively by the task which created the
459 *   associated object.
460 * @endparblock
461 */
462rtems_status_code rtems_rate_monotonic_period(
463  rtems_id       id,
464  rtems_interval length
465);
466
467/* Generated from spec:/rtems/ratemon/if/get-status */
468
469/**
470 * @ingroup RTEMSAPIClassicRatemon
471 *
472 * @brief Gets the detailed status of the period.
473 *
474 * @param id is the rate monotonic period identifier.
475 *
476 * @param[out] status is the pointer to an rtems_rate_monotonic_period_status
477 *   object.  When the directive call is successful, the detailed period status
478 *   will be stored in this object.
479 *
480 * This directive returns the detailed status of the rate monotonic period
481 * specified by ``id``.  The detailed status of the period will be returned in
482 * the members of the period status object referenced by ``status``:
483 *
484 * * The ``owner`` member is set to the identifier of the owner task of the
485 *   period.
486 *
487 * * The ``state`` member is set to the current state of the period.
488 *
489 * * The ``postponed_jobs_count`` member is set to the count of jobs which are
490 *   not released yet.
491 *
492 * * If the current state of the period is ::RATE_MONOTONIC_INACTIVE, the
493 *   ``since_last_period`` and ``executed_since_last_period`` members will be
494 *   set to zero.  Otherwise, both members will contain time information since
495 *   the last successful invocation of the rtems_rate_monotonic_period()
496 *   directive by the owner task.  More specifically, the ``since_last_period``
497 *   member will be set to the time elapsed since the last successful
498 *   invocation.  The ``executed_since_last_period`` member will be set to the
499 *   processor time consumed by the owner task since the last successful
500 *   invocation.
501 *
502 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
503 *
504 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
505 *   with the identifier specified by ``id``.
506 *
507 * @retval ::RTEMS_INVALID_ADDRESS The ``status`` parameter was NULL.
508 *
509 * @par Constraints
510 * @parblock
511 * The following constraints apply to this directive:
512 *
513 * * The directive may be called from within task context.
514 *
515 * * The directive may be called from within interrupt context.
516 *
517 * * The directive will not cause the calling task to be preempted.
518 * @endparblock
519 */
520rtems_status_code rtems_rate_monotonic_get_status(
521  rtems_id                            id,
522  rtems_rate_monotonic_period_status *status
523);
524
525/* Generated from spec:/rtems/ratemon/if/get-statistics */
526
527/**
528 * @ingroup RTEMSAPIClassicRatemon
529 *
530 * @brief Gets the statistics of the period.
531 *
532 * @param id is the rate monotonic period identifier.
533 *
534 * @param[out] status is the pointer to an
535 *   rtems_rate_monotonic_period_statistics object.  When the directive call is
536 *   successful, the period statistics will be stored in this object.
537 *
538 * This directive returns the statistics of the rate monotonic period specified
539 * by ``id``.  The statistics of the period will be returned in the members of
540 * the period statistics object referenced by ``status``:
541 *
542 * * The ``count`` member is set to the number of periods executed.
543 *
544 * * The ``missed_count`` member is set to the number of periods missed.
545 *
546 * * The ``min_cpu_time`` member is set to the least amount of processor time
547 *   used in the period.
548 *
549 * * The ``max_cpu_time`` member is set to the highest amount of processor time
550 *   used in the period.
551 *
552 * * The ``total_cpu_time`` member is set to the total amount of processor time
553 *   used in the period.
554 *
555 * * The ``min_wall_time`` member is set to the least amount of CLOCK_MONOTONIC
556 *   time used in the period.
557 *
558 * * The ``max_wall_time`` member is set to the highest amount of
559 *   CLOCK_MONOTONIC time used in the period.
560 *
561 * * The ``total_wall_time`` member is set to the total amount of
562 *   CLOCK_MONOTONIC time used in the period.
563 *
564 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
565 *
566 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
567 *   with the identifier specified by ``id``.
568 *
569 * @retval ::RTEMS_INVALID_ADDRESS The ``status`` parameter was NULL.
570 *
571 * @par Constraints
572 * @parblock
573 * The following constraints apply to this directive:
574 *
575 * * The directive may be called from within task context.
576 *
577 * * The directive may be called from within interrupt context.
578 *
579 * * The directive will not cause the calling task to be preempted.
580 * @endparblock
581 */
582rtems_status_code rtems_rate_monotonic_get_statistics(
583  rtems_id                                id,
584  rtems_rate_monotonic_period_statistics *status
585);
586
587/* Generated from spec:/rtems/ratemon/if/reset-statistics */
588
589/**
590 * @ingroup RTEMSAPIClassicRatemon
591 *
592 * @brief Resets the statistics of the period.
593 *
594 * @param id is the rate monotonic period identifier.
595 *
596 * This directive resets the statistics of the rate monotonic period specified
597 * by ``id``.
598 *
599 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
600 *
601 * @retval ::RTEMS_INVALID_ID There was no rate monotonic period associated
602 *   with the identifier specified by ``id``.
603 *
604 * @par Constraints
605 * @parblock
606 * The following constraints apply to this directive:
607 *
608 * * The directive may be called from within task context.
609 *
610 * * The directive may be called from within interrupt context.
611 *
612 * * The directive will not cause the calling task to be preempted.
613 * @endparblock
614 */
615rtems_status_code rtems_rate_monotonic_reset_statistics( rtems_id id );
616
617/* Generated from spec:/rtems/ratemon/if/reset-all-statistics */
618
619/**
620 * @ingroup RTEMSAPIClassicRatemon
621 *
622 * @brief Resets the statistics of all periods.
623 *
624 * This directive resets the statistics information associated with all rate
625 * monotonic period instances.
626 *
627 * @par Constraints
628 * @parblock
629 * The following constraints apply to this directive:
630 *
631 * * The directive may be called from within task context.
632 *
633 * * The directive may obtain and release the object allocator mutex.  This may
634 *   cause the calling task to be preempted.
635 * @endparblock
636 */
637void rtems_rate_monotonic_reset_all_statistics( void );
638
639/* Generated from spec:/rtems/ratemon/if/report-statistics */
640
641/**
642 * @ingroup RTEMSAPIClassicRatemon
643 *
644 * @brief Reports the period statistics using the printk() printer.
645 *
646 * This directive prints a report on all active periods which have executed at
647 * least one period using the printk() printer.
648 *
649 * @par Constraints
650 * @parblock
651 * The following constraints apply to this directive:
652 *
653 * * The directive may be called from within task context.
654 *
655 * * The directive may obtain and release the object allocator mutex.  This may
656 *   cause the calling task to be preempted.
657 * @endparblock
658 */
659void rtems_rate_monotonic_report_statistics( void );
660
661/* Generated from spec:/rtems/ratemon/if/report-statistics-with-plugin */
662
663/**
664 * @ingroup RTEMSAPIClassicRatemon
665 *
666 * @brief Reports the period statistics using the printer plugin.
667 *
668 * @param printer is the printer plugin to output the report.
669 *
670 * This directive prints a report on all active periods which have executed at
671 * least one period using the printer plugin specified by ``printer``.
672 *
673 * @par Constraints
674 * @parblock
675 * The following constraints apply to this directive:
676 *
677 * * The directive may be called from within task context.
678 *
679 * * The directive may obtain and release the object allocator mutex.  This may
680 *   cause the calling task to be preempted.
681 * @endparblock
682 */
683void rtems_rate_monotonic_report_statistics_with_plugin(
684  const struct rtems_printer *printer
685);
686
687#ifdef __cplusplus
688}
689#endif
690
691#endif /* _RTEMS_RTEMS_RATEMON_H */
Note: See TracBrowser for help on using the repository browser.