source:
rtems/cpukit/rtems/src/timerserverfireafter.c
@
17bbadd
Last change on this file since 17bbadd was 17bbadd, checked in by Joel Sherrill <joel.sherrill@…>, on 05/06/04 at 19:20:04 | |
---|---|
|
|
File size: 2.3 KB |
Line | |
---|---|
1 | /* |
2 | * Timer Manager - rtems_timer_server 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.rtems.com/license/LICENSE. |
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_server_fire_after |
27 | * |
28 | * This directive allows a thread to start a timer which will by |
29 | * executed by the Timer Server when it fires. |
30 | * |
31 | * Input parameters: |
32 | * id - timer id |
33 | * ticks - interval until routine is fired |
34 | * routine - routine to schedule |
35 | * user_data - passed as argument to routine when it is fired |
36 | * |
37 | * Output parameters: |
38 | * RTEMS_SUCCESSFUL - if successful |
39 | * error code - if unsuccessful |
40 | */ |
41 | |
42 | rtems_status_code rtems_timer_server_fire_after( |
43 | Objects_Id id, |
44 | rtems_interval ticks, |
45 | rtems_timer_service_routine_entry routine, |
46 | void *user_data |
47 | ) |
48 | { |
49 | Timer_Control *the_timer; |
50 | Objects_Locations location; |
51 | extern Chain_Control _Timer_Ticks_chain; |
52 | |
53 | if ( !_Timer_Server ) |
54 | return RTEMS_INCORRECT_STATE; |
55 | |
56 | if ( !routine ) |
57 | return RTEMS_INVALID_ADDRESS; |
58 | |
59 | if ( ticks == 0 ) |
60 | return RTEMS_INVALID_NUMBER; |
61 | |
62 | the_timer = _Timer_Get( id, &location ); |
63 | switch ( location ) { |
64 | case OBJECTS_REMOTE: /* should never return this */ |
65 | return RTEMS_INTERNAL_ERROR; |
66 | |
67 | case OBJECTS_ERROR: |
68 | return RTEMS_INVALID_ID; |
69 | |
70 | case OBJECTS_LOCAL: |
71 | (void) _Watchdog_Remove( &the_timer->Ticker ); |
72 | the_timer->the_class = TIMER_INTERVAL_ON_TASK; |
73 | _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data ); |
74 | the_timer->Ticker.initial = ticks; |
75 | |
76 | _Timer_Server_stop_ticks_timer(); |
77 | _Timer_Server_process_ticks_chain(); |
78 | _Watchdog_Insert( &_Timer_Ticks_chain, &the_timer->Ticker ); |
79 | _Timer_Server_reset_ticks_timer(); |
80 | |
81 | _Thread_Enable_dispatch(); |
82 | return RTEMS_SUCCESSFUL; |
83 | } |
84 | |
85 | return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ |
86 | } |
Note: See TracBrowser
for help on using the repository browser.