source: rtems/cpukit/rtems/include/rtems/rtems/ratemonimpl.h @ 03b900d

5
Last change on this file since 03b900d was 03b900d, checked in by Sebastian Huber <sebastian.huber@…>, on 02/18/16 at 07:36:26

score: Replace watchdog handler implementation

Use a red-black tree instead of delta chains.

Close #2344.
Update #2554.
Update #2555.
Close #2606.

  • Property mode set to 100644
File size: 6.0 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicRateMonImpl
5 *
6 * @brief Classic Rate Monotonic Scheduler Implementation
7 */
8
9/*  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#ifndef _RTEMS_RTEMS_RATEMONIMPL_H
18#define _RTEMS_RTEMS_RATEMONIMPL_H
19
20#include <rtems/rtems/ratemon.h>
21#include <rtems/score/objectimpl.h>
22
23#include <string.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/**
30 * @defgroup ClassicRateMonImpl Classic Rate Monotonic Scheduler Implementation
31 *
32 * @ingroup ClassicRateMon
33 *
34 * @{
35 */
36
37/**
38 *  @brief Rate Monotonic Period Class Management Structure
39 *
40 *  This instance of Objects_Information is used to manage the
41 *  set of rate monotonic period instances.
42 */
43extern Objects_Information _Rate_monotonic_Information;
44
45/**
46 *  @brief Allocates a period control block from
47 *  the inactive chain of free period control blocks.
48 *
49 *  This function allocates a period control block from
50 *  the inactive chain of free period control blocks.
51 */
52RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void )
53{
54  return (Rate_monotonic_Control *)
55    _Objects_Allocate( &_Rate_monotonic_Information );
56}
57
58/**
59 *  @brief Allocates a period control block from
60 *  the inactive chain of free period control blocks.
61 *
62 *  This routine allocates a period control block from
63 *  the inactive chain of free period control blocks.
64 */
65RTEMS_INLINE_ROUTINE void _Rate_monotonic_Free (
66  Rate_monotonic_Control *the_period
67)
68{
69  _Objects_Free( &_Rate_monotonic_Information, &the_period->Object );
70}
71
72/**
73 *  @brief Maps period IDs to period control blocks.
74 *
75 *  This function maps period IDs to period control blocks.
76 *  If ID corresponds to a local period, then it returns
77 *  the_period control pointer which maps to ID and location
78 *  is set to OBJECTS_LOCAL.  Otherwise, location is set
79 *  to OBJECTS_ERROR and the_period is undefined.
80 */
81RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get (
82  Objects_Id         id,
83  Objects_Locations *location
84)
85{
86  return (Rate_monotonic_Control *)
87    _Objects_Get( &_Rate_monotonic_Information, id, location );
88}
89
90/**
91 *  @brief Checks if the_period is in the ACTIVE state.
92 *
93 *  This function returns TRUE if the_period is in the ACTIVE state,
94 *  and FALSE otherwise.
95 */
96RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_active (
97  Rate_monotonic_Control *the_period
98)
99{
100  return (the_period->state == RATE_MONOTONIC_ACTIVE);
101}
102
103/**
104 *  @brief Checks if the_period is in the ACTIVE state.
105 *
106 *  This function returns TRUE if the_period is in the ACTIVE state,
107 *  and FALSE otherwise.
108 */
109RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_inactive (
110  Rate_monotonic_Control *the_period
111)
112{
113  return (the_period->state == RATE_MONOTONIC_INACTIVE);
114}
115
116/**
117 *  @brief Checks if the_period is in the EXPIRED state.
118 *
119 *  This function returns TRUE if the_period is in the EXPIRED state,
120 *  and FALSE otherwise.
121 */
122RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_expired (
123  Rate_monotonic_Control *the_period
124)
125{
126  return (the_period->state == RATE_MONOTONIC_EXPIRED);
127}
128
129/**
130 * @brief Rate Monotonic Timeout
131 *
132 * This routine is invoked when the period represented by the watchdog expires.
133 * If the thread which owns this period is blocked waiting for the period to
134 * expire, then it is readied and the period is restarted. If the owning thread
135 * is not waiting for the period to expire, then the period is placed in the
136 * EXPIRED state and not restarted.
137 */
138void _Rate_monotonic_Timeout( Watchdog_Control *watchdog );
139
140/**
141 * @brief _Rate_monotonic_Get_status(
142 *
143 * This routine is invoked to compute the elapsed wall time and cpu
144 * time for a period.
145 *
146 * @param[in] the_period points to the period being operated upon.
147 * @param[out] wall_since_last_period is set to the wall time elapsed
148 *             since the period was initiated.
149 * @param[out] cpu_since_last_period is set to the cpu time used by the
150 *             owning thread since the period was initiated.
151 *
152 * @retval This routine returns true if the status can be determined
153 *         and false otherwise.
154 */
155bool _Rate_monotonic_Get_status(
156  Rate_monotonic_Control        *the_period,
157  Rate_monotonic_Period_time_t  *wall_since_last_period,
158  Timestamp_Control             *cpu_since_last_period
159);
160
161/**
162 *  @brief Restart Rate Monotonic Period
163 *
164 *  This routine is invoked when a period is initiated via an explicit
165 *  call to rtems_rate_monotonic_period for the period's first iteration
166 *  or from _Rate_monotonic_Timeout for period iterations 2-n.
167 *
168 *  @param[in] the_period points to the period being operated upon.
169 */
170void _Rate_monotonic_Restart(
171  Rate_monotonic_Control *the_period
172);
173
174/**
175 *  @brief _Rate_monotonic_Reset_wall_time_statistics
176 *
177 *  This method resets the statistics information for a period instance.
178 */
179#define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
180   do { \
181      /* set the minimums to a large value */ \
182      _Timestamp_Set( \
183        &(_the_period)->Statistics.min_wall_time, \
184        0x7fffffff, \
185        0x7fffffff \
186      ); \
187   } while (0)
188
189/**
190 *  @brief Rate_monotonic_Reset_cpu_use_statistics
191 *
192 *  This helper method resets the period CPU usage statistics structure.
193 */
194#define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
195   do { \
196      /* set the minimums to a large value */ \
197      _Timestamp_Set( \
198        &(_the_period)->Statistics.min_cpu_time, \
199        0x7fffffff, \
200        0x7fffffff \
201      ); \
202   } while (0)
203
204/**
205 *  @brief Rate_monotonic_Reset_statistics
206 *
207 *  This helper method resets the period wall time statistics structure.
208 */
209#define _Rate_monotonic_Reset_statistics( _the_period ) \
210  do { \
211    memset( \
212      &(_the_period)->Statistics, \
213      0, \
214      sizeof( rtems_rate_monotonic_period_statistics ) \
215    ); \
216    _Rate_monotonic_Reset_cpu_use_statistics( _the_period ); \
217    _Rate_monotonic_Reset_wall_time_statistics( _the_period ); \
218  } while (0)
219
220/**@}*/
221
222#ifdef __cplusplus
223}
224#endif
225
226#endif
227/* end of include file */
Note: See TracBrowser for help on using the repository browser.