1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2013. |
---|
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.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #define CONFIGURE_INIT |
---|
15 | #include "system.h" |
---|
16 | |
---|
17 | const char rtems_test_name[] = "TIME TEST 6"; |
---|
18 | |
---|
19 | rtems_id Task_id[ OPERATION_COUNT + 1 ]; |
---|
20 | |
---|
21 | uint32_t Task_restarted; |
---|
22 | |
---|
23 | rtems_task null_task( |
---|
24 | rtems_task_argument argument |
---|
25 | ); |
---|
26 | |
---|
27 | rtems_task Task_1( |
---|
28 | rtems_task_argument argument |
---|
29 | ); |
---|
30 | |
---|
31 | void test_init( void ); |
---|
32 | |
---|
33 | rtems_task Init( |
---|
34 | rtems_task_argument argument |
---|
35 | ) |
---|
36 | { |
---|
37 | rtems_status_code status; |
---|
38 | |
---|
39 | Print_Warning(); |
---|
40 | |
---|
41 | TEST_BEGIN(); |
---|
42 | |
---|
43 | test_init(); |
---|
44 | |
---|
45 | status = rtems_task_delete( RTEMS_SELF ); |
---|
46 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
47 | } |
---|
48 | |
---|
49 | void test_init( void ) |
---|
50 | { |
---|
51 | rtems_status_code status; |
---|
52 | rtems_id id; |
---|
53 | |
---|
54 | Task_restarted = OPERATION_COUNT; |
---|
55 | |
---|
56 | status = rtems_task_create( |
---|
57 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
58 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u, |
---|
59 | RTEMS_MINIMUM_STACK_SIZE, |
---|
60 | RTEMS_DEFAULT_MODES, |
---|
61 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
62 | &id |
---|
63 | ); |
---|
64 | directive_failed( status, "rtems_task_create" ); |
---|
65 | |
---|
66 | status = rtems_task_start( id, Task_1, 0 ); |
---|
67 | directive_failed( status, "rtems_task_start" ); |
---|
68 | } |
---|
69 | |
---|
70 | rtems_task Task_1( |
---|
71 | rtems_task_argument argument |
---|
72 | ) |
---|
73 | { |
---|
74 | rtems_status_code status; |
---|
75 | uint32_t index; |
---|
76 | |
---|
77 | if ( Task_restarted == OPERATION_COUNT ) |
---|
78 | benchmark_timer_initialize(); |
---|
79 | |
---|
80 | Task_restarted--; |
---|
81 | |
---|
82 | if ( Task_restarted != 0 ) |
---|
83 | (void) rtems_task_restart( RTEMS_SELF, 0 ); |
---|
84 | |
---|
85 | end_time = benchmark_timer_read(); |
---|
86 | |
---|
87 | benchmark_timer_initialize(); |
---|
88 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
89 | (void) benchmark_timer_empty_function(); |
---|
90 | overhead = benchmark_timer_read(); |
---|
91 | |
---|
92 | put_time( |
---|
93 | "rtems_task_restart: calling task", |
---|
94 | end_time, |
---|
95 | OPERATION_COUNT, |
---|
96 | overhead, |
---|
97 | 0 |
---|
98 | ); |
---|
99 | |
---|
100 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
101 | status = rtems_task_create( |
---|
102 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
103 | RTEMS_MAXIMUM_PRIORITY - 1u, |
---|
104 | RTEMS_MINIMUM_STACK_SIZE, |
---|
105 | RTEMS_DEFAULT_MODES, |
---|
106 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
107 | &Task_id[ index ] |
---|
108 | ); |
---|
109 | directive_failed( status, "rtems_task_create loop" ); |
---|
110 | |
---|
111 | status = rtems_task_start( Task_id[ index ], null_task, 0 ); |
---|
112 | directive_failed( status, "rtems_task_start loop" ); |
---|
113 | } |
---|
114 | |
---|
115 | benchmark_timer_initialize(); |
---|
116 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
117 | (void) rtems_task_suspend( Task_id[ index ] ); |
---|
118 | end_time = benchmark_timer_read(); |
---|
119 | |
---|
120 | put_time( |
---|
121 | "rtems_task_suspend: returns to caller", |
---|
122 | end_time, |
---|
123 | OPERATION_COUNT, |
---|
124 | 0, |
---|
125 | 0 |
---|
126 | ); |
---|
127 | |
---|
128 | benchmark_timer_initialize(); |
---|
129 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
130 | (void) rtems_task_resume( Task_id[ index ] ); |
---|
131 | end_time = benchmark_timer_read(); |
---|
132 | |
---|
133 | put_time( |
---|
134 | "rtems_task_resume: task readied returns to caller", |
---|
135 | end_time, |
---|
136 | OPERATION_COUNT, |
---|
137 | 0, |
---|
138 | 0 |
---|
139 | ); |
---|
140 | |
---|
141 | benchmark_timer_initialize(); |
---|
142 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
143 | (void) rtems_task_delete( Task_id[ index ] ); |
---|
144 | end_time = benchmark_timer_read(); |
---|
145 | |
---|
146 | put_time( |
---|
147 | "rtems_task_delete: ready task", |
---|
148 | end_time, |
---|
149 | OPERATION_COUNT, |
---|
150 | 0, |
---|
151 | 0 |
---|
152 | ); |
---|
153 | |
---|
154 | TEST_END(); |
---|
155 | rtems_test_exit( 0 ); |
---|
156 | } |
---|
157 | |
---|
158 | rtems_task null_task( |
---|
159 | rtems_task_argument argument |
---|
160 | ) |
---|
161 | { |
---|
162 | while ( FOREVER ) |
---|
163 | ; |
---|
164 | } |
---|