source: rtems/doc/user/timer.t @ 372a382a

4.104.114.84.95
Last change on this file since 372a382a was 372a382a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/18/97 at 15:04:19

Fixed typo of "::"

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