1 | /* |
---|
2 | * COPYRIGHT (c) 2011. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <tmacros.h> |
---|
15 | |
---|
16 | /* |
---|
17 | * Keep the names and IDs in global variables so another task can use them. |
---|
18 | */ |
---|
19 | rtems_id Task_id[ 4 ]; /* array of task ids */ |
---|
20 | rtems_name Task_name[ 4 ]; /* array of task names */ |
---|
21 | |
---|
22 | rtems_task Test_task( |
---|
23 | rtems_task_argument unused |
---|
24 | ) |
---|
25 | { |
---|
26 | rtems_id tid; |
---|
27 | rtems_time_of_day time; |
---|
28 | uint32_t task_index; |
---|
29 | rtems_status_code status; |
---|
30 | |
---|
31 | status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); |
---|
32 | directive_failed( status, "task ident" ); |
---|
33 | |
---|
34 | task_index = task_number( tid ); |
---|
35 | for ( ; ; ) { |
---|
36 | status = rtems_clock_get_tod( &time ); |
---|
37 | directive_failed( status, "clock get tod" ); |
---|
38 | if ( time.second >= 35 ) { |
---|
39 | puts( "*** END OF SIMPLE01 TEST ***" ); |
---|
40 | rtems_test_exit( 0 ); |
---|
41 | } |
---|
42 | put_name( Task_name[ task_index ], FALSE ); |
---|
43 | print_time( " - rtems_clock_get_tod - ", &time, "\n" ); |
---|
44 | status = rtems_task_wake_after( |
---|
45 | task_index * 5 * rtems_clock_get_ticks_per_second() |
---|
46 | ); |
---|
47 | directive_failed( status, "wake after" ); |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | rtems_task Init( |
---|
52 | rtems_task_argument argument |
---|
53 | ) |
---|
54 | { |
---|
55 | rtems_status_code status; |
---|
56 | rtems_time_of_day time; |
---|
57 | rtems_task_priority old; |
---|
58 | |
---|
59 | puts( "\n\n*** SIMPLE01 TEST ***" ); |
---|
60 | |
---|
61 | time.year = 1988; |
---|
62 | time.month = 12; |
---|
63 | time.day = 31; |
---|
64 | time.hour = 9; |
---|
65 | time.minute = 0; |
---|
66 | time.second = 0; |
---|
67 | time.ticks = 0; |
---|
68 | |
---|
69 | status = rtems_clock_set( &time ); |
---|
70 | |
---|
71 | Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); |
---|
72 | Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); |
---|
73 | Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); |
---|
74 | |
---|
75 | status = rtems_task_create( |
---|
76 | Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, |
---|
77 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] |
---|
78 | ); |
---|
79 | directive_failed( status, "create 1" ); |
---|
80 | |
---|
81 | status = rtems_task_create( |
---|
82 | Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, |
---|
83 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] |
---|
84 | ); |
---|
85 | directive_failed( status, "create 2" ); |
---|
86 | |
---|
87 | status = rtems_task_create( |
---|
88 | Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, |
---|
89 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] |
---|
90 | ); |
---|
91 | directive_failed( status, "create 3" ); |
---|
92 | |
---|
93 | status = rtems_task_start( Task_id[ 1 ], Test_task, 1 ); |
---|
94 | directive_failed( status, "start 1" ); |
---|
95 | rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
96 | |
---|
97 | status = rtems_task_start( Task_id[ 2 ], Test_task, 2 ); |
---|
98 | directive_failed( status, "start 2" ); |
---|
99 | rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
100 | |
---|
101 | status = rtems_task_start( Task_id[ 3 ], Test_task, 3 ); |
---|
102 | directive_failed( status, "start 3" ); |
---|
103 | |
---|
104 | status = rtems_task_set_priority( Task_id[1], 2, &old ); |
---|
105 | directive_failed( status, "set priority 1" ); |
---|
106 | status = rtems_task_set_priority( Task_id[2], 2, &old ); |
---|
107 | directive_failed( status, "set priority 2" ); |
---|
108 | status = rtems_task_set_priority( Task_id[3], 2, &old ); |
---|
109 | directive_failed( status, "set priority 3" ); |
---|
110 | |
---|
111 | status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
112 | directive_failed( status, "yield" ); |
---|
113 | |
---|
114 | status = rtems_task_delete( RTEMS_SELF ); |
---|
115 | directive_failed( status, "delete self" ); |
---|
116 | } |
---|
117 | |
---|
118 | /* configuration information */ |
---|
119 | #include <bsp.h> /* for device driver prototypes */ |
---|
120 | |
---|
121 | #define CONFIGURE_SCHEDULER_SIMPLE |
---|
122 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
123 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
124 | |
---|
125 | #define CONFIGURE_MAXIMUM_TASKS 4 |
---|
126 | |
---|
127 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
128 | |
---|
129 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
---|
130 | |
---|
131 | #define CONFIGURE_INIT |
---|
132 | #include <rtems/confdefs.h> |
---|
133 | /* end of file */ |
---|