source: rtems/doc/user/timer.t @ 20515fc

4.104.114.84.95
Last change on this file since 20515fc was 20515fc, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/98 at 18:53:17

Nodes, menus, etc are automatically generated now

  • Property mode set to 100644
File size: 12.8 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-1998.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter Timer Manager
10
11@section Introduction
12
13The timer manager provides support for timer
14facilities.  The directives provided by the timer manager are:
15
16@itemize @bullet
17@item @code{@value{DIRPREFIX}timer_create} - Create a timer
18@item @code{@value{DIRPREFIX}timer_ident} - Get ID of a timer
19@item @code{@value{DIRPREFIX}timer_cancel} - Cancel a timer
20@item @code{@value{DIRPREFIX}timer_delete} - Delete a timer
21@item @code{@value{DIRPREFIX}timer_fire_after} - Fire timer after interval
22@item @code{@value{DIRPREFIX}timer_fire_when} - Fire timer when specified
23@item @code{@value{DIRPREFIX}timer_reset} - Reset an interval timer
24@end itemize
25
26
27@section Background
28
29@subsection Required Support
30
31A clock tick is required to support the functionality provided by this manager.
32
33@subsection Timers
34
35A timer is an RTEMS object which allows the
36application to schedule operations to occur at specific times in
37the future.  User supplied timer service routines are invoked by
38the @code{@value{DIRPREFIX}clock_tick} directive
39when the timer fires.  Timer service routines may perform
40any operations or directives which normally
41would be performed by the application code which invoked the
42@code{@value{DIRPREFIX}clock_tick} directive.
43
44The timer can be used to implement watchdog routines
45which only fire to denote that an application error has
46occurred.  The timer is reset at specific points in the
47application to insure that the watchdog does not fire.  Thus, if
48the application does not reset the watchdog timer, then the
49timer service routine will fire to indicate that the application
50has failed to reach a reset point.  This use of a timer is
51sometimes referred to as a "keep alive" or a "deadman" timer.
52
53@subsection Timer Service Routines
54
55The timer service routine should adhere to @value{LANGUAGE} calling
56conventions and have a prototype similar to the following:
57
58@ifset is-C
59@example
60rtems_timer_service_routine user_routine(
61  rtems_id   timer_id,
62  void      *user_data
63);
64@end example
65@end ifset
66
67@ifset is-Ada
68@example
69procedure User_Routine(
70  Timer_ID  : in     RTEMS.ID;
71  User_Data : in     System.Address
72);
73@end example
74@end ifset
75
76Where the timer_id parameter is the RTEMS object ID
77of the timer which is being fired and user_data is a pointer to
78user-defined information which may be utilized by the timer
79service routine.  The argument user_data may be NULL.
80
81@section Operations
82
83@subsection Creating a Timer
84
85The @code{@value{DIRPREFIX}timer_create} directive creates a timer by
86allocating a Timer Control Block (TMCB), assigning the timer a
87user-specified name, and assigning it a timer ID.  Newly created
88timers do not have a timer service routine associated with them
89and are not active.
90
91@subsection Obtaining Timer IDs
92
93When a timer is created, RTEMS generates a unique
94timer ID and assigns it to the created timer until it is
95deleted.  The timer ID may be obtained by either of two methods.
96First, as the result of an invocation of the
97@code{@value{DIRPREFIX}timer_create}
98directive, the timer ID is stored in a user provided location.
99Second, the timer ID may be obtained later using the
100@code{@value{DIRPREFIX}timer_ident} directive.  The timer ID
101is used by other directives to manipulate this timer.
102
103@subsection Initiating an Interval Timer
104
105The @code{@value{DIRPREFIX}timer_fire_after} directive initiates a timer to
106fire a user provided timer service routine after the specified
107number of clock ticks have elapsed.  When the interval has
108elapsed, the timer service routine will be invoked from the
109@code{@value{DIRPREFIX}clock_tick} directive.
110
111@subsection Initiating a Time of Day Timer
112
113The @code{@value{DIRPREFIX}timer_fire_when} directive initiates a timer to
114fire a user provided timer service routine when the specified
115time of day has been reached.  When the interval has elapsed,
116the timer service routine will be invoked from the
117@code{@value{DIRPREFIX}clock_tick} directive.
118
119@subsection Canceling a Timer
120
121The @code{@value{DIRPREFIX}timer_cancel} directive is used to halt the
122specified timer.  Once canceled, the timer service routine will
123not fire unless the timer is reinitiated.  The timer can be
124reinitiated using the @code{@value{DIRPREFIX}timer_reset},
125@code{@value{DIRPREFIX}timer_fire_after}, and
126@code{@value{DIRPREFIX}timer_fire_when} directives.
127
128@subsection Resetting a Timer
129
130The @code{@value{DIRPREFIX}timer_reset} directive is used to restore an
131interval timer initiated by a previous invocation of
132@code{@value{DIRPREFIX}timer_fire_after} to
133its original interval length.  If the
134timer has not been used or the last usage of this timer
135was by a @code{@value{DIRPREFIX}timer_fire_when} directive, then an error is
136returned.  The timer service routine is not changed or
137fired by this directive.
138
139@subsection Deleting a Timer
140
141The @code{@value{DIRPREFIX}timer_delete} directive is used to delete a timer.
142If the timer is running and has not expired, the timer is
143automatically canceled.  The timer's control block is returned
144to the TMCB free list when it is deleted.  A timer can be
145deleted by a task other than the task which created the timer.
146Any subsequent references to the timer's name and ID are invalid.
147
148@section Directives
149
150This section details the timer manager's directives.
151A subsection is dedicated to each of this manager's directives
152and describes the calling sequence, related constants, usage,
153and status codes.
154
155@page
156@subsection TIMER_CREATE - Create a timer
157
158@subheading CALLING SEQUENCE:
159
160@ifset is-C
161@example
162rtems_status_code rtems_timer_create(
163  rtems_name  name,
164  rtems_id   *id
165);
166@end example
167@end ifset
168
169@ifset is-Ada
170@example
171procedure Timer_Create (
172   Name   : in     RTEMS.Name;
173   ID     :    out RTEMS.ID;
174   Result :    out RTEMS.Status_Codes
175);
176@end example
177@end ifset
178
179@subheading DIRECTIVE STATUS CODES:
180@code{@value{RPREFIX}SUCCESSFUL} - timer created successfully@*
181@code{@value{RPREFIX}INVALID_NAME} - invalid timer name@*
182@code{@value{RPREFIX}TOO_MANY} - too many timers created
183
184@subheading DESCRIPTION:
185
186This directive creates a timer.  The assigned timer
187id is returned in id.  This id is used to access the timer with
188other timer manager directives.  For control and maintenance of
189the timer, RTEMS allocates a TMCB from the local TMCB free pool
190and initializes it.
191
192@subheading NOTES:
193
194This directive will not cause the calling task to be
195preempted.
196
197@page
198@subsection TIMER_IDENT - Get ID of a timer
199
200@subheading CALLING SEQUENCE:
201
202@ifset is-C
203@example
204rtems_status_code rtems_timer_ident(
205  rtems_name  name,
206  rtems_id   *id
207);
208@end example
209@end ifset
210
211@ifset is-Ada
212@example
213procedure Timer_Ident (
214   Name   : in     RTEMS.Name;
215   ID     :    out RTEMS.ID;
216   Result :    out RTEMS.Status_Codes
217);
218@end example
219@end ifset
220
221@subheading DIRECTIVE STATUS CODES:
222@code{@value{RPREFIX}SUCCESSFUL} - timer identified successfully@*
223@code{@value{RPREFIX}INVALID_NAME} - timer name not found
224
225@subheading DESCRIPTION:
226
227This directive obtains the timer id associated with
228the timer name to be acquired.  If the timer name is not unique,
229then the timer id will match one of the timers with that name.
230However, this timer id is not guaranteed to correspond to the
231desired timer.  The timer id is used to access this timer in
232other timer related directives.
233
234@subheading NOTES:
235
236This directive will not cause the running task to be
237preempted.
238
239@page
240@subsection TIMER_CANCEL - Cancel a timer
241
242@subheading CALLING SEQUENCE:
243
244@ifset is-C
245@example
246rtems_status_code rtems_timer_cancel(
247  rtems_id id
248);
249@end example
250@end ifset
251
252@ifset is-Ada
253@example
254procedure Timer_Cancel (
255   ID     : in     RTEMS.ID;
256   Result :    out RTEMS.Status_Codes
257);
258@end example
259@end ifset
260
261@subheading DIRECTIVE STATUS CODES:
262@code{@value{RPREFIX}SUCCESSFUL} - timer canceled successfully@*
263@code{@value{RPREFIX}INVALID_ID} - invalid timer id
264
265@subheading DESCRIPTION:
266
267This directive cancels the timer id.  This timer will
268be reinitiated by the next invocation of @code{@value{DIRPREFIX}timer_reset},
269@code{@value{DIRPREFIX}timer_fire_after}, or
270@code{@value{DIRPREFIX}timer_fire_when} with id.
271
272@subheading NOTES:
273
274This directive will not cause the running task to be preempted.
275
276@page
277@subsection TIMER_DELETE - Delete a timer
278
279@subheading CALLING SEQUENCE:
280
281@ifset is-C
282@example
283rtems_status_code rtems_timer_delete(
284  rtems_id id
285);
286@end example
287@end ifset
288
289@ifset is-Ada
290@example
291procedure Timer_Delete (
292   ID     : in     RTEMS.ID;
293   Result :    out RTEMS.Status_Codes
294);
295@end example
296@end ifset
297
298@subheading DIRECTIVE STATUS CODES:
299@code{@value{RPREFIX}SUCCESSFUL} - timer deleted successfully@*
300@code{@value{RPREFIX}INVALID_ID} - invalid timer id
301
302@subheading DESCRIPTION:
303
304This directive deletes the timer specified by id.  If
305the timer is running, it is automatically canceled.  The TMCB
306for the deleted timer is reclaimed by RTEMS.
307
308@subheading NOTES:
309
310This directive will not cause the running task to be
311preempted.
312
313A timer can be deleted by a task other than the task
314which created the timer.
315
316@page
317@subsection TIMER_FIRE_AFTER - Fire timer after interval
318
319@subheading CALLING SEQUENCE:
320
321@ifset is-C
322@example
323rtems_status_code rtems_timer_fire_after(
324  rtems_id                           id,
325  rtems_interval                     ticks,
326  rtems_timer_service_routine_entry  routine,
327  void                              *user_data
328);
329@end example
330@end ifset
331
332@ifset is-Ada
333@example
334procedure Timer_Fire_After (
335   ID        : in     RTEMS.ID;
336   Ticks     : in     RTEMS.Interval;
337   Routine   : in     RTEMS.Timer_Service_Routine;
338   User_Data : in     RTEMS.Address;
339   Result    :    out RTEMS.Status_Codes
340);
341@end example
342@end ifset
343
344@subheading DIRECTIVE STATUS CODES:
345@code{@value{RPREFIX}SUCCESSFUL} - timer initiated successfully@*
346@code{@value{RPREFIX}INVALID_ID} - invalid timer id@*
347@code{@value{RPREFIX}INVALID_NUMBER} - invalid interval
348
349@subheading DESCRIPTION:
350
351This directive initiates the timer specified by id.
352If the timer is running, it is automatically canceled before
353being initiated.  The timer is scheduled to fire after an
354interval ticks clock ticks has passed.  When the timer fires,
355the timer service routine routine will be invoked with the
356argument user_data.
357
358@subheading NOTES:
359
360This directive will not cause the running task to be
361preempted.
362
363@page
364@subsection TIMER_FIRE_WHEN - Fire timer when specified
365
366@subheading CALLING SEQUENCE:
367
368@ifset is-C
369@example
370rtems_status_code rtems_timer_fire_when(
371  rtems_id                           id,
372  rtems_time_of_day                 *wall_time,
373  rtems_timer_service_routine_entry  routine,
374  void                              *user_data
375);
376@end example
377@end ifset
378
379@ifset is-Ada
380@example
381procedure Timer_Fire_When (
382   ID        : in     RTEMS.ID;
383   Wall_Time : in     RTEMS.Time_Of_Day;
384   Routine   : in     RTEMS.Timer_Service_Routine;
385   User_Data : in     RTEMS.Address;
386   Result    :    out RTEMS.Status_Codes
387);
388@end example
389@end ifset
390
391@subheading DIRECTIVE STATUS CODES:
392@code{@value{RPREFIX}SUCCESSFUL} - timer initiated successfully@*
393@code{@value{RPREFIX}INVALID_ID} - invalid timer id@*
394@code{@value{RPREFIX}NOT_DEFINED} - system date and time is not set@*
395@code{@value{RPREFIX}INVALID_CLOCK} - invalid time of day
396
397@subheading DESCRIPTION:
398
399This directive initiates the timer specified by id.
400If the timer is running, it is automatically canceled before
401being initiated.  The timer is scheduled to fire at the time of
402day specified by wall_time.  When the timer fires, the timer
403service routine routine will be invoked with the argument
404user_data.
405
406@subheading NOTES:
407
408This directive will not cause the running task to be
409preempted.
410
411@page
412@subsection TIMER_RESET - Reset an interval timer
413
414@subheading CALLING SEQUENCE:
415
416@ifset is-C
417@example
418rtems_status_code rtems_timer_reset(
419  rtems_id   id
420);
421@end example
422@end ifset
423
424@ifset is-Ada
425@example
426procedure Timer_Reset (
427   ID     : in     RTEMS.ID;
428   Result :    out RTEMS.Status_Codes
429);
430@end example
431@end ifset
432
433@subheading DIRECTIVE STATUS CODES:
434@code{@value{RPREFIX}SUCCESSFUL} - timer reset successfully@*
435@code{@value{RPREFIX}INVALID_ID} - invalid timer id@*
436@code{@value{RPREFIX}NOT_DEFINED} - attempted to reset a when or newly created timer
437
438@subheading DESCRIPTION:
439
440This directive resets the timer associated with id.
441This timer must have been previously initiated with a
442@code{@value{DIRPREFIX}timer_fire_after}
443directive.  If active the timer is canceled,
444after which the timer is reinitiated using the same interval and
445timer service routine which the original
446@code{@value{DIRPREFIX}timer_fire_after}
447directive used.
448
449@subheading NOTES:
450
451If the timer has not been used or the last usage of this timer
452was by a @code{@value{DIRPREFIX}timer_fire_when}
453directive, then the @code{@value{RPREFIX}NOT_DEFINED} error is
454returned.
455
456Restarting a cancelled after timer results in the timer being
457reinitiated with its previous timer service routine and interval.
458
459This directive will not cause the running task to be preempted.
460
Note: See TracBrowser for help on using the repository browser.