1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Task Wake After |
---|
5 | * @ingroup ClassicTasks |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/rtems/status.h> |
---|
23 | #include <rtems/rtems/support.h> |
---|
24 | #include <rtems/rtems/modes.h> |
---|
25 | #include <rtems/score/object.h> |
---|
26 | #include <rtems/score/scheduler.h> |
---|
27 | #include <rtems/score/stack.h> |
---|
28 | #include <rtems/score/states.h> |
---|
29 | #include <rtems/rtems/tasks.h> |
---|
30 | #include <rtems/score/thread.h> |
---|
31 | #include <rtems/score/threadq.h> |
---|
32 | #include <rtems/score/tod.h> |
---|
33 | #include <rtems/score/wkspace.h> |
---|
34 | #include <rtems/score/apiext.h> |
---|
35 | #include <rtems/score/sysstate.h> |
---|
36 | #include <rtems/score/watchdogimpl.h> |
---|
37 | |
---|
38 | rtems_status_code rtems_task_wake_after( |
---|
39 | rtems_interval ticks |
---|
40 | ) |
---|
41 | { |
---|
42 | /* |
---|
43 | * It is critical to obtain the executing thread after thread dispatching is |
---|
44 | * disabled on SMP configurations. |
---|
45 | */ |
---|
46 | Thread_Control *executing; |
---|
47 | |
---|
48 | _Thread_Disable_dispatch(); |
---|
49 | executing = _Thread_Executing; |
---|
50 | |
---|
51 | if ( ticks == 0 ) { |
---|
52 | _Scheduler_Yield( executing ); |
---|
53 | } else { |
---|
54 | _Thread_Set_state( executing, STATES_DELAYING ); |
---|
55 | _Watchdog_Initialize( |
---|
56 | &executing->Timer, |
---|
57 | _Thread_Delay_ended, |
---|
58 | executing->Object.id, |
---|
59 | NULL |
---|
60 | ); |
---|
61 | _Watchdog_Insert_ticks( &executing->Timer, ticks ); |
---|
62 | } |
---|
63 | _Thread_Enable_dispatch(); |
---|
64 | return RTEMS_SUCCESSFUL; |
---|
65 | } |
---|