1 | /* ratemon.h |
---|
2 | * |
---|
3 | * This include file contains all the constants, structures, and |
---|
4 | * prototypes associated with the Rate Monotonic Manager. This manager |
---|
5 | * provides facilities to implement tasks which execute in a periodic fashion. |
---|
6 | * |
---|
7 | * Directives provided are: |
---|
8 | * |
---|
9 | * + create a rate monotonic timer |
---|
10 | * + cancel a period |
---|
11 | * + delete a rate monotonic timer |
---|
12 | * + conclude current and start the next period |
---|
13 | * |
---|
14 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
15 | * On-Line Applications Research Corporation (OAR). |
---|
16 | * All rights assigned to U.S. Government, 1994. |
---|
17 | * |
---|
18 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
19 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
20 | * notice must appear in all copies of this file and its derivatives. |
---|
21 | * |
---|
22 | * $Id$ |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef __RTEMS_RATE_MONOTONIC_h |
---|
26 | #define __RTEMS_RATE_MONOTONIC_h |
---|
27 | |
---|
28 | #ifdef __cplusplus |
---|
29 | extern "C" { |
---|
30 | #endif |
---|
31 | |
---|
32 | #include <rtems/score/object.h> |
---|
33 | #include <rtems/score/thread.h> |
---|
34 | #include <rtems/score/watchdog.h> |
---|
35 | |
---|
36 | /* |
---|
37 | * The following enumerated type defines the states in which a |
---|
38 | * period may be. |
---|
39 | */ |
---|
40 | |
---|
41 | typedef enum { |
---|
42 | RATE_MONOTONIC_INACTIVE, /* off chain, never initialized */ |
---|
43 | RATE_MONOTONIC_OWNER_IS_BLOCKING, /* on chain, owner is blocking on it */ |
---|
44 | RATE_MONOTONIC_ACTIVE, /* on chain, running continuously */ |
---|
45 | RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING, /* on chain, expired while owner was */ |
---|
46 | /* was blocking on it */ |
---|
47 | RATE_MONOTONIC_EXPIRED /* off chain, will be reset by next */ |
---|
48 | /* rtems_rate_monotonic_period */ |
---|
49 | } Rate_Monotonic_Period_states; |
---|
50 | |
---|
51 | /* |
---|
52 | * The following constant is the interval passed to the rate_monontonic_period |
---|
53 | * directive to obtain status information. |
---|
54 | */ |
---|
55 | |
---|
56 | #define RTEMS_PERIOD_STATUS WATCHDOG_NO_TIMEOUT |
---|
57 | |
---|
58 | /* |
---|
59 | * The following structure defines the control block used to manage |
---|
60 | * each period. |
---|
61 | */ |
---|
62 | |
---|
63 | typedef struct { |
---|
64 | Objects_Control Object; |
---|
65 | Watchdog_Control Timer; |
---|
66 | Rate_Monotonic_Period_states state; |
---|
67 | Thread_Control *owner; |
---|
68 | } Rate_monotonic_Control; |
---|
69 | |
---|
70 | EXTERN Objects_Information _Rate_monotonic_Information; |
---|
71 | |
---|
72 | /* |
---|
73 | * _Rate_monotonic_Manager_initialization |
---|
74 | * |
---|
75 | * DESCRIPTION: |
---|
76 | * |
---|
77 | * This routine performs the initialization necessary for this manager. |
---|
78 | */ |
---|
79 | |
---|
80 | void _Rate_monotonic_Manager_initialization( |
---|
81 | unsigned32 maximum_periods |
---|
82 | ); |
---|
83 | |
---|
84 | /* |
---|
85 | * rtems_rate_monotonic_create |
---|
86 | * |
---|
87 | * DESCRIPTION: |
---|
88 | * |
---|
89 | * This routine implements the rate_monotonic_create directive. The |
---|
90 | * period will have the name name. It returns the id of the |
---|
91 | * created period in ID. |
---|
92 | */ |
---|
93 | |
---|
94 | rtems_status_code rtems_rate_monotonic_create( |
---|
95 | rtems_name name, |
---|
96 | Objects_Id *id |
---|
97 | ); |
---|
98 | |
---|
99 | /* |
---|
100 | * rtems_rate_monotonic_ident |
---|
101 | * |
---|
102 | * DESCRIPTION: |
---|
103 | * |
---|
104 | * This routine implements the rtems_rate_monotonic_ident directive. |
---|
105 | * This directive returns the period ID associated with name. |
---|
106 | * If more than one period is named name, then the period |
---|
107 | * to which the ID belongs is arbitrary. |
---|
108 | */ |
---|
109 | |
---|
110 | rtems_status_code rtems_rate_monotonic_ident( |
---|
111 | rtems_name name, |
---|
112 | Objects_Id *id |
---|
113 | ); |
---|
114 | |
---|
115 | /* |
---|
116 | * rtems_rate_monotonic_cancel |
---|
117 | * |
---|
118 | * DESCRIPTION: |
---|
119 | * |
---|
120 | * This routine implements the rtems_rate_monotonic_cancel directive. This |
---|
121 | * directive stops the period associated with ID from continuing to |
---|
122 | * run. |
---|
123 | */ |
---|
124 | |
---|
125 | rtems_status_code rtems_rate_monotonic_cancel( |
---|
126 | Objects_Id id |
---|
127 | ); |
---|
128 | |
---|
129 | /* |
---|
130 | * rtems_rate_monotonic_delete |
---|
131 | * |
---|
132 | * DESCRIPTION: |
---|
133 | * |
---|
134 | * This routine implements the rtems_rate_monotonic_delete directive. The |
---|
135 | * period indicated by ID is deleted. |
---|
136 | */ |
---|
137 | |
---|
138 | rtems_status_code rtems_rate_monotonic_delete( |
---|
139 | Objects_Id id |
---|
140 | ); |
---|
141 | |
---|
142 | /* |
---|
143 | * rtems_rate_monotonic_period |
---|
144 | * |
---|
145 | * DESCRIPTION: |
---|
146 | * |
---|
147 | * This routine implements the rtems_rate_monotonic_period directive. When |
---|
148 | * length is non-zero, this directive initiates the period associated with |
---|
149 | * ID from continuing for a period of length. If length is zero, then |
---|
150 | * result is set to indicate the current state of the period. |
---|
151 | */ |
---|
152 | |
---|
153 | rtems_status_code rtems_rate_monotonic_period( |
---|
154 | Objects_Id id, |
---|
155 | rtems_interval length |
---|
156 | ); |
---|
157 | |
---|
158 | /* |
---|
159 | * _Rate_monotonic_Allocate |
---|
160 | * |
---|
161 | * DESCRIPTION: |
---|
162 | * |
---|
163 | * This function allocates a period control block from |
---|
164 | * the inactive chain of free period control blocks. |
---|
165 | */ |
---|
166 | |
---|
167 | STATIC INLINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void ); |
---|
168 | |
---|
169 | /* |
---|
170 | * _Rate_monotonic_Free |
---|
171 | * |
---|
172 | * DESCRIPTION: |
---|
173 | * |
---|
174 | * This routine allocates a period control block from |
---|
175 | * the inactive chain of free period control blocks. |
---|
176 | */ |
---|
177 | |
---|
178 | STATIC INLINE void _Rate_monotonic_Free ( |
---|
179 | Rate_monotonic_Control *the_period |
---|
180 | ); |
---|
181 | |
---|
182 | /* |
---|
183 | * _Rate_monotonic_Get |
---|
184 | * |
---|
185 | * DESCRIPTION: |
---|
186 | * |
---|
187 | * This function maps period IDs to period control blocks. |
---|
188 | * If ID corresponds to a local period, then it returns |
---|
189 | * the_period control pointer which maps to ID and location |
---|
190 | * is set to OBJECTS_LOCAL. Otherwise, location is set |
---|
191 | * to OBJECTS_ERROR and the_period is undefined. |
---|
192 | */ |
---|
193 | |
---|
194 | STATIC INLINE Rate_monotonic_Control *_Rate_monotonic_Get ( |
---|
195 | Objects_Id id, |
---|
196 | Objects_Locations *location |
---|
197 | ); |
---|
198 | |
---|
199 | /* |
---|
200 | * _Rate_monotonic_Timeout |
---|
201 | * |
---|
202 | * DESCRIPTION: |
---|
203 | * |
---|
204 | * This routine is invoked when the period represented |
---|
205 | * by ID expires. If the task which owns this period is blocked |
---|
206 | * waiting for the period to expire, then it is readied and the |
---|
207 | * period is restarted. If the owning task is not waiting for the |
---|
208 | * period to expire, then the period is placed in the EXPIRED |
---|
209 | * state and not restarted. |
---|
210 | */ |
---|
211 | |
---|
212 | void _Rate_monotonic_Timeout ( |
---|
213 | Objects_Id id, |
---|
214 | void *ignored |
---|
215 | ); |
---|
216 | |
---|
217 | /* |
---|
218 | * _Rate_monotonic_Is_active |
---|
219 | * |
---|
220 | * DESCRIPTION: |
---|
221 | * |
---|
222 | * This function returns TRUE if the_period is in the ACTIVE state, |
---|
223 | * and FALSE otherwise. |
---|
224 | */ |
---|
225 | |
---|
226 | STATIC INLINE boolean _Rate_monotonic_Is_active ( |
---|
227 | Rate_monotonic_Control *the_period |
---|
228 | ); |
---|
229 | |
---|
230 | /* |
---|
231 | * _Rate_monotonic_Is_inactive |
---|
232 | * |
---|
233 | * DESCRIPTION: |
---|
234 | * |
---|
235 | * This function returns TRUE if the_period is in the ACTIVE state, |
---|
236 | * and FALSE otherwise. |
---|
237 | */ |
---|
238 | |
---|
239 | STATIC INLINE boolean _Rate_monotonic_Is_inactive ( |
---|
240 | Rate_monotonic_Control *the_period |
---|
241 | ); |
---|
242 | |
---|
243 | /* |
---|
244 | * _Rate_monotonic_Is_expired |
---|
245 | * |
---|
246 | * DESCRIPTION: |
---|
247 | * |
---|
248 | * This function returns TRUE if the_period is in the EXPIRED state, |
---|
249 | * and FALSE otherwise. |
---|
250 | */ |
---|
251 | |
---|
252 | STATIC INLINE boolean _Rate_monotonic_Is_expired ( |
---|
253 | Rate_monotonic_Control *the_period |
---|
254 | ); |
---|
255 | |
---|
256 | /* |
---|
257 | * _Rate_monotonic_Is_null |
---|
258 | * |
---|
259 | * DESCRIPTION: |
---|
260 | * |
---|
261 | * This function returns TRUE if the_period is NULL and FALSE otherwise. |
---|
262 | */ |
---|
263 | |
---|
264 | STATIC INLINE boolean _Rate_monotonic_Is_null ( |
---|
265 | Rate_monotonic_Control *the_period |
---|
266 | ); |
---|
267 | |
---|
268 | #include <rtems/rtems/ratemon.inl> |
---|
269 | |
---|
270 | #ifdef __cplusplus |
---|
271 | } |
---|
272 | #endif |
---|
273 | |
---|
274 | #endif |
---|
275 | /* end of include file */ |
---|