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

Last change on this file was a2ed06e, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 22:29:38

cpukit/include/rtems/rtems/*.h: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSImplClassicRateMonotonic
7 *
8 * @brief This header file provides data structures used by the implementation
9 *   and the @ref RTEMSImplApplConfig to define ::_Rate_monotonic_Information.
10 */
11
12/* COPYRIGHT (c) 1989-2009, 2016.
13 * On-Line Applications Research Corporation (OAR).
14 * COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
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#ifndef _RTEMS_RTEMS_RATEMONDATA_H
39#define _RTEMS_RTEMS_RATEMONDATA_H
40
41#include <rtems/rtems/ratemon.h>
42#include <rtems/score/timestamp.h>
43#include <rtems/score/thread.h>
44#include <rtems/score/watchdog.h>
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/**
51 * @addtogroup RTEMSImplClassicRateMonotonic
52 *
53 * @{
54 */
55
56/**
57 *  The following defines the INTERNAL data structure that has the
58 *  statistics kept on each period instance.
59 */
60typedef struct {
61  /** This field contains the number of periods executed. */
62  uint32_t     count;
63  /** This field contains the number of periods missed. */
64  uint32_t     missed_count;
65
66  /** This field contains the least amount of CPU time used in a period. */
67  Timestamp_Control min_cpu_time;
68  /** This field contains the highest amount of CPU time used in a period. */
69  Timestamp_Control max_cpu_time;
70  /** This field contains the total amount of wall time used in a period. */
71  Timestamp_Control total_cpu_time;
72
73  /** This field contains the least amount of wall time used in a period. */
74  Timestamp_Control min_wall_time;
75  /** This field contains the highest amount of wall time used in a period. */
76  Timestamp_Control max_wall_time;
77  /** This field contains the total amount of CPU time used in a period. */
78  Timestamp_Control total_wall_time;
79}  Rate_monotonic_Statistics;
80
81/**
82 * @brief The following structure defines the control block used to manage each
83 * period.
84 *
85 * State changes are protected by the default thread lock of the owner thread.
86 * The owner thread is the thread that created the period object.  The owner
87 * thread field is immutable after object creation.
88 */
89typedef struct {
90  /** This field is the object management portion of a Period instance. */
91  Objects_Control                         Object;
92
93#if defined(RTEMS_SMP)
94  /**
95   * @brief Protects the rate monotonic period state.
96   */
97  ISR_lock_Control                        Lock;
98#endif
99
100  /** This is the timer used to provide the unblocking mechanism. */
101  Watchdog_Control                        Timer;
102
103  /** This field indicates the current state of the period. */
104  rtems_rate_monotonic_period_states      state;
105
106  /**
107   * @brief A priority node for use by the scheduler job release and cancel
108   * operations.
109   */
110  Priority_Node                           Priority;
111
112  /**
113   * This field contains the length of the next period to be
114   * executed.
115   */
116  uint32_t                                next_length;
117
118  /**
119   * This field contains a pointer to the TCB for the thread
120   * which owns and uses this period instance.
121   */
122  Thread_Control                         *owner;
123
124  /**
125   * This field contains the cpu usage value of the owning thread when
126   * the period was initiated.  It is used to compute the period's
127   * statistics.
128   */
129  Timestamp_Control                       cpu_usage_period_initiated;
130
131  /**
132   * This field contains the wall time value when the period
133   * was initiated.  It is used to compute the period's statistics.
134   */
135  Timestamp_Control                       time_period_initiated;
136
137  /**
138   * This field contains the statistics maintained for the period.
139   */
140  Rate_monotonic_Statistics               Statistics;
141
142  /**
143   * This field contains the number of postponed jobs.
144   * When the watchdog timeout, this variable will be increased immediately.
145   */
146  uint32_t                                postponed_jobs;
147
148  /**
149   *  This field contains the tick of the latest deadline decided by the period
150   *  watchdog.
151  */
152  uint64_t                                latest_deadline;
153}   Rate_monotonic_Control;
154
155/**
156 * @brief The Classic Rate Monotonic objects information.
157 */
158extern Objects_Information _Rate_monotonic_Information;
159
160/**
161 * @brief Macro to define the objects information for the Classic Rate
162 * Monotonic objects.
163 *
164 * This macro should only be used by <rtems/confdefs.h>.
165 *
166 * @param max The configured object maximum (the OBJECTS_UNLIMITED_OBJECTS flag
167 * may be set).
168 */
169#define RATE_MONOTONIC_INFORMATION_DEFINE( max ) \
170  OBJECTS_INFORMATION_DEFINE( \
171    _Rate_monotonic, \
172    OBJECTS_CLASSIC_API, \
173    OBJECTS_RTEMS_PERIODS, \
174    Rate_monotonic_Control, \
175    max, \
176    OBJECTS_NO_STRING_NAME, \
177    NULL \
178  )
179
180/** @} */
181
182#ifdef __cplusplus
183}
184#endif
185
186#endif
187/* end of include file */
Note: See TracBrowser for help on using the repository browser.