source:
rtems/cpukit/rtems/src/taskwakewhen.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: 1.9 KB |
Line | |
---|---|
1 | /* |
2 | * RTEMS Task Manager |
3 | * |
4 | * |
5 | * COPYRIGHT (c) 1989-1999. |
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/rtems/modes.h> |
19 | #include <rtems/score/object.h> |
20 | #include <rtems/score/stack.h> |
21 | #include <rtems/score/states.h> |
22 | #include <rtems/rtems/tasks.h> |
23 | #include <rtems/score/thread.h> |
24 | #include <rtems/score/threadq.h> |
25 | #include <rtems/score/tod.h> |
26 | #include <rtems/score/userext.h> |
27 | #include <rtems/score/wkspace.h> |
28 | #include <rtems/score/apiext.h> |
29 | #include <rtems/score/sysstate.h> |
30 | |
31 | /*PAGE |
32 | * |
33 | * rtems_task_wake_when |
34 | * |
35 | * This directive blocks the requesting thread until the given date and |
36 | * time is reached. |
37 | * |
38 | * Input parameters: |
39 | * time_buffer - pointer to the time and date structure |
40 | * |
41 | * Output parameters: |
42 | * RTEMS_SUCCESSFUL - if successful |
43 | * error code - if unsuccessful |
44 | */ |
45 | |
46 | rtems_status_code rtems_task_wake_when( |
47 | rtems_time_of_day *time_buffer |
48 | ) |
49 | { |
50 | Watchdog_Interval seconds; |
51 | |
52 | if ( !_TOD_Is_set ) |
53 | return RTEMS_NOT_DEFINED; |
54 | |
55 | if ( !time_buffer ) |
56 | return RTEMS_INVALID_ADDRESS; |
57 | |
58 | time_buffer->ticks = 0; |
59 | |
60 | if ( !_TOD_Validate( time_buffer ) ) |
61 | return RTEMS_INVALID_CLOCK; |
62 | |
63 | seconds = _TOD_To_seconds( time_buffer ); |
64 | |
65 | if ( seconds <= _TOD_Seconds_since_epoch ) |
66 | return RTEMS_INVALID_CLOCK; |
67 | |
68 | _Thread_Disable_dispatch(); |
69 | _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_TIME ); |
70 | _Watchdog_Initialize( |
71 | &_Thread_Executing->Timer, |
72 | _Thread_Delay_ended, |
73 | _Thread_Executing->Object.id, |
74 | NULL |
75 | ); |
76 | _Watchdog_Insert_seconds( |
77 | &_Thread_Executing->Timer, |
78 | seconds - _TOD_Seconds_since_epoch |
79 | ); |
80 | _Thread_Enable_dispatch(); |
81 | return RTEMS_SUCCESSFUL; |
82 | } |
Note: See TracBrowser
for help on using the repository browser.