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 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #ifdef HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <tmacros.h> |
---|
17 | |
---|
18 | /* |
---|
19 | * Keep the names and IDs in global variables so another task can use them. |
---|
20 | */ |
---|
21 | rtems_id Task_id[ 4 ]; /* array of task ids */ |
---|
22 | rtems_name Task_name[ 4 ]; /* array of task names */ |
---|
23 | |
---|
24 | rtems_task Test_task( |
---|
25 | rtems_task_argument unused |
---|
26 | ) |
---|
27 | { |
---|
28 | rtems_id tid; |
---|
29 | rtems_time_of_day time; |
---|
30 | uint32_t task_index; |
---|
31 | rtems_status_code status; |
---|
32 | |
---|
33 | status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); |
---|
34 | task_index = task_number( tid ); |
---|
35 | for ( ; ; ) { |
---|
36 | status = rtems_clock_get_tod( &time ); |
---|
37 | if ( time.second >= 35 ) { |
---|
38 | puts( "*** END OF SIMPLE01 TEST ***" ); |
---|
39 | rtems_test_exit( 0 ); |
---|
40 | } |
---|
41 | put_name( Task_name[ task_index ], FALSE ); |
---|
42 | print_time( " - rtems_clock_get_tod - ", &time, "\n" ); |
---|
43 | status = rtems_task_wake_after( |
---|
44 | task_index * 5 * rtems_clock_get_ticks_per_second() ); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | rtems_task Init( |
---|
49 | rtems_task_argument argument |
---|
50 | ) |
---|
51 | { |
---|
52 | rtems_status_code status; |
---|
53 | rtems_time_of_day time; |
---|
54 | rtems_task_priority old; |
---|
55 | |
---|
56 | puts( "\n\n*** SIMPLE01 TEST ***" ); |
---|
57 | |
---|
58 | time.year = 1988; |
---|
59 | time.month = 12; |
---|
60 | time.day = 31; |
---|
61 | time.hour = 9; |
---|
62 | time.minute = 0; |
---|
63 | time.second = 0; |
---|
64 | time.ticks = 0; |
---|
65 | |
---|
66 | status = rtems_clock_set( &time ); |
---|
67 | |
---|
68 | Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ); |
---|
69 | Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' ); |
---|
70 | Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' ); |
---|
71 | |
---|
72 | status = rtems_task_create( |
---|
73 | Task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, |
---|
74 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ] |
---|
75 | ); |
---|
76 | status = rtems_task_create( |
---|
77 | Task_name[ 2 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, |
---|
78 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ] |
---|
79 | ); |
---|
80 | status = rtems_task_create( |
---|
81 | Task_name[ 3 ], 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES, |
---|
82 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 3 ] |
---|
83 | ); |
---|
84 | |
---|
85 | status = rtems_task_start( Task_id[ 1 ], Test_task, 1 ); |
---|
86 | rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
87 | status = rtems_task_start( Task_id[ 2 ], Test_task, 2 ); |
---|
88 | rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
89 | status = rtems_task_start( Task_id[ 3 ], Test_task, 3 ); |
---|
90 | |
---|
91 | rtems_task_set_priority(Task_id[1], 2, &old); |
---|
92 | rtems_task_set_priority(Task_id[2], 2, &old); |
---|
93 | rtems_task_set_priority(Task_id[3], 2, &old); |
---|
94 | |
---|
95 | rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
96 | |
---|
97 | status = rtems_task_delete( RTEMS_SELF ); |
---|
98 | } |
---|
99 | |
---|
100 | /* configuration information */ |
---|
101 | #include <bsp.h> /* for device driver prototypes */ |
---|
102 | |
---|
103 | #define CONFIGURE_SCHEDULER_SIMPLE |
---|
104 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
105 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
106 | |
---|
107 | #define CONFIGURE_MAXIMUM_TASKS 4 |
---|
108 | |
---|
109 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
110 | |
---|
111 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
---|
112 | |
---|
113 | #define CONFIGURE_INIT |
---|
114 | #include <rtems/confdefs.h> |
---|
115 | /* end of file */ |
---|