source: rtems/doc/user/timer.t @ 1e524995

4.104.114.84.95
Last change on this file since 1e524995 was 1e524995, checked in by Joel Sherrill <joel.sherrill@…>, on 02/06/98 at 14:14:30

Updated copyrights

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