source: rtems/cpukit/rtems/src/timerfireafter.c @ c55df85

4.104.114.84.95
Last change on this file since c55df85 was c55df85, checked in by Joel Sherrill <joel.sherrill@…>, on 01/16/02 at 22:09:50

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: 1.9 KB
Line 
1/*
2 *  Timer Manager - rtems_timer_fire_after directive
3 *
4 *
5 *  COPYRIGHT (c) 1989-2002.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/rtems/status.h>
17#include <rtems/rtems/support.h>
18#include <rtems/score/object.h>
19#include <rtems/score/thread.h>
20#include <rtems/rtems/timer.h>
21#include <rtems/score/tod.h>
22#include <rtems/score/watchdog.h>
23
24/*PAGE
25 *
26 *  rtems_timer_fire_after
27 *
28 *  This directive allows a thread to start a timer.
29 *
30 *  Input parameters:
31 *    id        - timer id
32 *    ticks     - interval until routine is fired
33 *    routine   - routine to schedule
34 *    user_data - passed as argument to routine when it is fired
35 *
36 *  Output parameters:
37 *    RTEMS_SUCCESSFUL - if successful
38 *    error code       - if unsuccessful
39 */
40
41rtems_status_code rtems_timer_fire_after(
42  Objects_Id                         id,
43  rtems_interval                     ticks,
44  rtems_timer_service_routine_entry  routine,
45  void                              *user_data
46)
47{
48  Timer_Control      *the_timer;
49  Objects_Locations   location;
50
51  if ( ticks == 0 )
52    return RTEMS_INVALID_NUMBER;
53
54  the_timer = _Timer_Get( id, &location );
55  switch ( location ) {
56    case OBJECTS_REMOTE:            /* should never return this */
57      return RTEMS_INTERNAL_ERROR;
58
59    case OBJECTS_ERROR:
60      return RTEMS_INVALID_ID;
61
62    case OBJECTS_LOCAL:
63      (void) _Watchdog_Remove( &the_timer->Ticker );
64      the_timer->the_class = TIMER_INTERVAL;
65      _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
66      _Watchdog_Insert_ticks( &the_timer->Ticker, ticks );
67      _Thread_Enable_dispatch();
68      return RTEMS_SUCCESSFUL;
69  }
70
71  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
72}
Note: See TracBrowser for help on using the repository browser.