source: rtems/c/src/exec/rtems/headers/ratemon.h @ eb5a7e07

4.104.114.84.95
Last change on this file since eb5a7e07 was 5e9b32b, checked in by Joel Sherrill <joel.sherrill@…>, on 09/26/95 at 19:27:15

posix support initially added

  • Property mode set to 100644
File size: 6.5 KB
Line 
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
29extern "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
41typedef enum {
42  RATE_MONOTONIC_INACTIVE,  /* off chain, never initialized */
43  RATE_MONOTONIC_ACTIVE,    /* on chain, running continuously */
44  RATE_MONOTONIC_EXPIRED    /* off chain, will be reset by next rm_period */
45}   Rate_Monotonic_Period_states;
46
47/*
48 *  The following constant is the interval passed to the rate_monontonic_period
49 *  directive to obtain status information.
50 */
51
52#define RTEMS_PERIOD_STATUS       WATCHDOG_NO_TIMEOUT
53
54/*
55 *  The following structure defines the control block used to manage
56 *  each period.
57 */
58
59typedef struct {
60  Objects_Control               Object;
61  Watchdog_Control              Timer;
62  Rate_Monotonic_Period_states  state;
63  Thread_Control               *owner;
64}   Rate_monotonic_Control;
65
66EXTERN Objects_Information _Rate_monotonic_Information;
67
68/*
69 *  _Rate_monotonic_Manager_initialization
70 *
71 *  DESCRIPTION:
72 *
73 *  This routine performs the initialization necessary for this manager.
74 */
75
76void _Rate_monotonic_Manager_initialization(
77  unsigned32 maximum_periods
78);
79
80/*
81 *  rtems_rate_monotonic_create
82 *
83 *  DESCRIPTION:
84 *
85 *  This routine implements the rate_monotonic_create directive.  The
86 *  period will have the name name.  It returns the id of the
87 *  created period in ID.
88 */
89
90rtems_status_code rtems_rate_monotonic_create(
91  rtems_name    name,
92  Objects_Id   *id
93);
94
95/*
96 *  rtems_rate_monotonic_ident
97 *
98 *  DESCRIPTION:
99 *
100 *  This routine implements the rtems_rate_monotonic_ident directive.
101 *  This directive returns the period ID associated with name.
102 *  If more than one period is named name, then the period
103 *  to which the ID belongs is arbitrary.
104 */
105
106rtems_status_code rtems_rate_monotonic_ident(
107  rtems_name    name,
108  Objects_Id   *id
109);
110
111/*
112 *  rtems_rate_monotonic_cancel
113 *
114 *  DESCRIPTION:
115 *
116 *  This routine implements the rtems_rate_monotonic_cancel directive.  This
117 *  directive stops the period associated with ID from continuing to
118 *  run.
119 */
120
121rtems_status_code rtems_rate_monotonic_cancel(
122  Objects_Id id
123);
124
125/*
126 *  rtems_rate_monotonic_delete
127 *
128 *  DESCRIPTION:
129 *
130 *  This routine implements the rtems_rate_monotonic_delete directive.  The
131 *  period indicated by ID is deleted.
132 */
133
134rtems_status_code rtems_rate_monotonic_delete(
135  Objects_Id id
136);
137
138/*
139 *  rtems_rate_monotonic_period
140 *
141 *  DESCRIPTION:
142 *
143 *  This routine implements the rtems_rate_monotonic_period directive.  When
144 *  length is non-zero, this directive initiates the period associated with
145 *  ID from continuing for a period of length.  If length is zero, then
146 *  result is set to indicate the current state of the period.
147 */
148
149rtems_status_code rtems_rate_monotonic_period(
150  Objects_Id      id,
151  rtems_interval  length
152);
153
154/*
155 *  _Rate_monotonic_Allocate
156 *
157 *  DESCRIPTION:
158 *
159 *  This function allocates a period control block from
160 *  the inactive chain of free period control blocks.
161 */
162
163STATIC INLINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void );
164
165/*
166 *  _Rate_monotonic_Free
167 *
168 *  DESCRIPTION:
169 *
170 *  This routine allocates a period control block from
171 *  the inactive chain of free period control blocks.
172 */
173
174STATIC INLINE void _Rate_monotonic_Free (
175  Rate_monotonic_Control *the_period
176);
177
178/*
179 *  _Rate_monotonic_Get
180 *
181 *  DESCRIPTION:
182 *
183 *  This function maps period IDs to period control blocks.
184 *  If ID corresponds to a local period, then it returns
185 *  the_period control pointer which maps to ID and location
186 *  is set to OBJECTS_LOCAL.  Otherwise, location is set
187 *  to OBJECTS_ERROR and the_period is undefined.
188 */
189
190STATIC INLINE Rate_monotonic_Control *_Rate_monotonic_Get (
191  Objects_Id         id,
192  Objects_Locations *location
193);
194
195/*
196 *  _Rate_monotonic_Set_state
197 *
198 *  DESCRIPTION:
199 *
200 *  This function blocks the calling task so that it is waiting for
201 *  a period to expire.  It returns TRUE if the task was successfully
202 *  blocked, and FALSE otherwise.
203 */
204
205boolean _Rate_monotonic_Set_state(
206  Rate_monotonic_Control *the_period
207);
208
209/*
210 *  _Rate_monotonic_Timeout
211 *
212 *  DESCRIPTION:
213 *
214 *  This routine is invoked when the period represented
215 *  by ID expires.  If the task which owns this period is blocked
216 *  waiting for the period to expire, then it is readied and the
217 *  period is restarted.  If the owning task is not waiting for the
218 *  period to expire, then the period is placed in the EXPIRED
219 *  state and not restarted.
220 */
221
222void _Rate_monotonic_Timeout (
223  Objects_Id  id,
224  void       *ignored
225);
226
227/*
228 *  _Rate_monotonic_Is_active
229 *
230 *  DESCRIPTION:
231 *
232 *  This function returns TRUE if the_period is in the ACTIVE state,
233 *  and FALSE otherwise.
234 */
235
236STATIC INLINE boolean _Rate_monotonic_Is_active (
237  Rate_monotonic_Control *the_period
238);
239
240/*
241 *  _Rate_monotonic_Is_inactive
242 *
243 *  DESCRIPTION:
244 *
245 *  This function returns TRUE if the_period is in the ACTIVE state,
246 *  and FALSE otherwise.
247 */
248
249STATIC INLINE boolean _Rate_monotonic_Is_inactive (
250  Rate_monotonic_Control *the_period
251);
252
253/*
254 *  _Rate_monotonic_Is_expired
255 *
256 *  DESCRIPTION:
257 *
258 *  This function returns TRUE if the_period is in the EXPIRED state,
259 *  and FALSE otherwise.
260 */
261
262STATIC INLINE boolean _Rate_monotonic_Is_expired (
263  Rate_monotonic_Control *the_period
264);
265
266/*
267 *  _Rate_monotonic_Is_null
268 *
269 *  DESCRIPTION:
270 *
271 *  This function returns TRUE if the_period is NULL and FALSE otherwise.
272 */
273
274STATIC INLINE boolean _Rate_monotonic_Is_null (
275  Rate_monotonic_Control *the_period
276);
277
278#include <rtems/rtems/ratemon.inl>
279
280#ifdef __cplusplus
281}
282#endif
283
284#endif
285/* end of include file */
Note: See TracBrowser for help on using the repository browser.