source: rtems/c/src/exec/rtems/include/rtems/rtems/timer.h @ c55df85

4.104.114.84.95
Last change on this file since c55df85 was c55df85, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 16, 2002 at 10:09:50 PM

2001-01-16 Joel Sherrill <joel@…>

  • Added task-based timers to the Timer Manager. This added three new directives:
    • rtems_timer_initiate_server
    • rtems_timer_server_fire_after
    • rtems_timer_server_fire_when

In the process of doing this, a number of cleanups were made.

  • src/timerserver.c, src/timerserverfireafter.c, src/timerserverfirewhen.c: New files.
  • include/timer/timer.h: Added new prototypes and supporting types.
  • inline/rtems/rtems/timer.h, macros/rtems/rtems/timer.h: Enhanced _Timer_Is_interval_class() to cover the class TIMER_INTERVAL_ON_TASK.
  • src/Makefile.am: Accounted for new files.
  • src/rtemstimer.c: Added initialization of _Timer_Server variable.
  • src/timercancel.c, src/timerreset.c: Account for addition of timer classes. Also corrected the headers.
  • src/timercreate.c, src/timerdelete.c, src/timerfireafter.c, src/timerfireafter.c, src/timerident.c: Corrected header.
  • Property mode set to 100644
File size: 8.2 KB
Line 
1/*  timer.h
2 *
3 *  This include file contains all the constants, structures, and
4 *  prototypes associated with the Timer Manager.  This manager provides
5 *  facilities to configure, initiate, cancel, and delete timers which will
6 *  fire at specified intervals of time.
7 *
8 *  Directives provided are:
9 *
10 *     + create a timer
11 *     + get an ID of a timer
12 *     + delete a timer
13 *     + set timer to fire in context of clock tick
14 *        - after a number of ticks have passed
15 *        - when a specified date and time has been reached
16 *     + initiate the timer server task
17 *     + set timer to fire in context of the timer server task
18 *        - after a number of ticks have passed
19 *        - when a specified date and time has been reached
20 *     + reset a timer
21 *     + cancel a time
22 *
23 *  COPYRIGHT (c) 1989-2002.
24 *  On-Line Applications Research Corporation (OAR).
25 *
26 *  The license and distribution terms for this file may be
27 *  found in the file LICENSE in this distribution or at
28 *  http://www.OARcorp.com/rtems/license.html.
29 *
30 *  $Id$
31 */
32
33#ifndef __RTEMS_TIMER_h
34#define __RTEMS_TIMER_h
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40#include <rtems/score/object.h>
41#include <rtems/score/tod.h>
42#include <rtems/score/watchdog.h>
43#include <rtems/rtems/attr.h>
44
45/*
46 *  The following enumerated type details the classes to which a timer
47 *  may belong.
48 */
49
50typedef enum {
51  TIMER_INTERVAL,
52  TIMER_INTERVAL_ON_TASK,
53  TIMER_TIME_OF_DAY,
54  TIMER_TIME_OF_DAY_ON_TASK,
55  TIMER_DORMANT
56} Timer_Classes;
57
58/*
59 *  The following types define a pointer to a timer service routine.
60 */
61 
62typedef void rtems_timer_service_routine;
63 
64typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )(
65                 rtems_id,
66                 void *
67             );
68
69/*
70 *  The following defines the information control block used to manage
71 *  this class of objects.
72 */
73
74RTEMS_EXTERN Objects_Information  _Timer_Information;
75
76/*
77 *  Pointer to TCB of the Timer Server.  This is NULL before the
78 *  server is executing and task-based timers are not allowed to be
79 *  initiated until the server is started.
80 */
81
82RTEMS_EXTERN Thread_Control *_Timer_Server;
83
84/* 
85 *  The following chains contain the list of interval timers that are
86 *  executed in the context of the Timer Server.
87 *
88 *  NOTE: These are extern'ed because they do not have to be in the
89 *        minimum footprint.  They are only really required when
90 *        task-based timers are used.  Since task-based timers can
91 *        not be started until the server is initiated, these structures
92 *        do not have to be initialized until then.  They are declared
93 *        in the same file as _Timer_Server_body.
94 */   
95
96extern Chain_Control _Timer_Ticks_chain;
97extern Chain_Control _Timer_Seconds_chain;
98
99/*
100 *  The following records define the control block used to manage
101 *  each timer.
102 */
103
104typedef struct {
105  Objects_Control  Object;
106  Watchdog_Control Ticker;
107  Timer_Classes    the_class;
108}   Timer_Control;
109
110/*
111 *  _Timer_Manager_initialization
112 *
113 *  DESCRIPTION:
114 *
115 *  This routine performs the initialization necessary for this manager.
116 */
117
118void _Timer_Manager_initialization(
119  unsigned32 maximum_timers
120);
121
122/*
123 *  _Timer_Server_body
124 *
125 *  DESCRIPTION:
126 *
127 *  This is the server for task based timers.  This task executes whenever
128 *  a task-based timer should fire.  It services both "after" and "when"
129 *  timers.  It is not created automatically but must be created explicitly
130 *  by the application before task-based timers may be initiated.
131 */
132
133Thread _Timer_Server_body(
134  unsigned32 ignored
135);
136
137/*
138 *  _Timer_Server_reset
139 *
140 *  DESCRIPTION:
141 *
142 *  This routine resets the timers which determine when the Timer Server
143 *  will wake up next to service task-based timers.
144 */
145
146typedef enum {
147  TIMER_SERVER_RESET_TICKS,
148  TIMER_SERVER_RESET_SECONDS
149} Timer_Server_reset_mode;
150
151void _Timer_Server_reset(
152  Timer_Server_reset_mode  reset_mode
153);
154
155/*
156 *  rtems_timer_create
157 *
158 *  DESCRIPTION:
159 *
160 *  This routine implements the rtems_timer_create directive.  The
161 *  timer will have the name name.  It returns the id of the
162 *  created timer in ID.
163 */
164
165rtems_status_code rtems_timer_create(
166  rtems_name    name,
167  Objects_Id   *id
168);
169
170/*
171 *  rtems_timer_ident
172 *
173 *  DESCRIPTION:
174 *
175 *  This routine implements the rtems_timer_ident directive.
176 *  This directive returns the timer ID associated with name.
177 *  If more than one timer is named name, then the timer
178 *  to which the ID belongs is arbitrary.
179 */
180
181rtems_status_code rtems_timer_ident(
182  rtems_name    name,
183  Objects_Id   *id
184);
185
186/*
187 *  rtems_timer_cancel
188 *
189 *  DESCRIPTION:
190 *
191 *  This routine implements the rtems_timer_cancel directive.  It is used
192 *  to stop the timer associated with ID from firing.
193 */
194
195rtems_status_code rtems_timer_cancel(
196  Objects_Id id
197);
198
199/*
200 *  rtems_timer_delete
201 *
202 *  DESCRIPTION:
203 *
204 *  This routine implements the rtems_timer_delete directive.  The
205 *  timer indicated by ID is deleted.
206 */
207
208rtems_status_code rtems_timer_delete(
209  Objects_Id id
210);
211
212/*
213 *  rtems_timer_fire_after
214 *
215 *  DESCRIPTION:
216 *
217 *  This routine implements the rtems_timer_fire_after directive.  It
218 *  initiates the timer associated with ID to fire in ticks clock ticks.
219 *  When the timer fires, the routine will be invoked in the context
220 *  of the rtems_clock_tick directive which is normally invoked as
221 *  part of servicing a periodic interupt.
222 */
223
224rtems_status_code rtems_timer_fire_after(
225  Objects_Id                         id,
226  rtems_interval                     ticks,
227  rtems_timer_service_routine_entry  routine,
228  void                              *user_data
229);
230
231/*
232 *  rtems_timer_server_fire_after
233 *
234 *  DESCRIPTION:
235 *
236 *  This routine implements the rtems_timer_server_fire_after directive.  It
237 *  initiates the timer associated with ID to fire in ticks clock
238 *  ticks.  When the timer fires, the routine will be invoked by the
239 *  Timer Server in the context of a task NOT IN THE CONTEXT of the
240 *  clock tick interrupt.
241 */
242
243rtems_status_code rtems_timer_server_fire_after(
244  Objects_Id                         id,
245  rtems_interval                     ticks,
246  rtems_timer_service_routine_entry  routine,
247  void                              *user_data
248);
249
250/*
251 *  rtems_timer_fire_when
252 *
253 *  DESCRIPTION:
254 *
255 *  This routine implements the rtems_timer_fire_when directive.  It
256 *  initiates the timer associated with ID to fire at wall_time
257 *  When the timer fires, the routine will be invoked in the context
258 *  of the rtems_clock_tick directive which is normally invoked as
259 *  part of servicing a periodic interupt.
260 */
261
262rtems_status_code rtems_timer_fire_when(
263  Objects_Id                          id,
264  rtems_time_of_day                  *wall_time,
265  rtems_timer_service_routine_entry   routine,
266  void                               *user_data
267);
268
269/*
270 *  rtems_timer_server_fire_when
271 *
272 *  DESCRIPTION:
273 *
274 *  This routine implements the rtems_timer_server_fire_when directive.  It
275 *  initiates the timer associated with ID to fire at wall_time
276 *  When the timer fires, the routine will be invoked by the
277 *  Timer Server in the context of a task NOT IN THE CONTEXT of the
278 *  clock tick interrupt.
279 */
280
281rtems_status_code rtems_timer_server_fire_when(
282  Objects_Id                          id,
283  rtems_time_of_day                  *wall_time,
284  rtems_timer_service_routine_entry   routine,
285  void                               *user_data
286);
287
288/*
289 *  rtems_timer_reset
290 *
291 *  DESCRIPTION:
292 *
293 *  This routine implements the rtems_timer_reset directive.  It is used
294 *  to reinitialize the interval timer associated with ID just as if
295 *  rtems_timer_fire_after were re-invoked with the same arguments that
296 *  were used to initiate this timer.
297 */
298
299rtems_status_code rtems_timer_reset(
300  Objects_Id id
301);
302
303/*
304 *  rtems_timer_initiate_server
305 *
306 *  DESCRIPTION:
307 *
308 *  This routine implements the rtems_timer_initiate_server directive.
309 *  It creates and starts the server that executes task-based timers.
310 *  It must be invoked before any task-based timers can be initiated.
311 */
312
313rtems_status_code rtems_timer_initiate_server(
314  unsigned32           stack_size,
315  rtems_attribute      attribute_set
316);
317
318#ifndef __RTEMS_APPLICATION__
319#include <rtems/rtems/timer.inl>
320#endif
321
322#ifdef __cplusplus
323}
324#endif
325
326#endif
327/* end of include file */
Note: See TracBrowser for help on using the repository browser.