source: rtems/testsuites/tmtests/tm21/task1.c @ 2ead50a

4.11
Last change on this file since 2ead50a was 2ead50a, checked in by bjorn larsson <bjornlarsson@…>, on Mar 21, 2014 at 3:48:01 PM

tmtests: convert to test.h

  • Property mode set to 100644
File size: 5.6 KB
Line 
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
17const char rtems_test_name[] = "TIME TEST 21";
18
19uint8_t   Region_area[ 2048 ] CPU_STRUCTURE_ALIGNMENT;
20uint8_t   Partition_area[ 2048 ] CPU_STRUCTURE_ALIGNMENT;
21
22rtems_task Task_1(
23  rtems_task_argument argument
24);
25
26rtems_task Init(
27  rtems_task_argument argument
28)
29{
30  rtems_id          id;
31  rtems_status_code status;
32
33  Print_Warning();
34
35  TEST_BEGIN();
36
37  status = rtems_task_create(
38    rtems_build_name( 'T', 'I', 'M', 'E' ),
39    RTEMS_MAXIMUM_PRIORITY - 5u,
40    RTEMS_MINIMUM_STACK_SIZE,
41    RTEMS_DEFAULT_MODES,
42    RTEMS_DEFAULT_ATTRIBUTES,
43    &id
44  );
45  directive_failed( status, "rtems_task_create of TASK1" );
46
47  status = rtems_task_start( id, Task_1, 0 );
48  directive_failed( status, "rtems_task_start of TASK1" );
49
50  status = rtems_task_delete( RTEMS_SELF );
51  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
52}
53
54#define MESSAGE_SIZE (sizeof(long) * 4)
55
56rtems_task Task_1(
57  rtems_task_argument argument
58)
59{
60  uint32_t    index;
61  rtems_id          id;
62  rtems_status_code status;
63
64  for( index = 1 ; index <= OPERATION_COUNT ; index++ ) {
65    status = rtems_task_create (
66      index,
67      RTEMS_MAXIMUM_PRIORITY - 1u,
68      RTEMS_MINIMUM_STACK_SIZE,
69      RTEMS_DEFAULT_MODES,
70      RTEMS_DEFAULT_ATTRIBUTES,
71      &id
72    );
73    directive_failed( status, "rtems_task_create" );
74
75    status = rtems_message_queue_create(
76      index,
77      1,                       /* only going to ident this queue */
78      MESSAGE_SIZE,
79      RTEMS_DEFAULT_ATTRIBUTES,
80      &id
81    );
82    directive_failed( status, "rtems_message_queue_create" );
83
84    status = rtems_semaphore_create(
85      index,
86      OPERATION_COUNT,
87      RTEMS_DEFAULT_ATTRIBUTES,
88      RTEMS_NO_PRIORITY,
89      &id
90    );
91    directive_failed( status, "rtems_semaphore_create" );
92
93    status = rtems_region_create(
94      index,
95      Region_area,
96      2048,
97      16,
98      RTEMS_DEFAULT_ATTRIBUTES,
99      &id
100    );
101    directive_failed( status, "rtems_region_create" );
102
103    status = rtems_partition_create(
104      index,
105      Partition_area,
106      2048,
107      128,
108      RTEMS_DEFAULT_ATTRIBUTES,
109      &id
110    );
111    directive_failed( status, "rtems_partition_create" );
112
113    status = rtems_port_create(
114      index,
115      Partition_area,
116      Region_area,
117      0xff,
118      &id
119    );
120    directive_failed( status, "rtems_port_create" );
121
122    status = rtems_timer_create( index, &id );
123    directive_failed( status, "rtems_timer_create" );
124
125    status = rtems_rate_monotonic_create( index, &id );
126    directive_failed( status, "rtems_rate_monotonic_create" );
127  }
128
129  benchmark_timer_initialize();
130    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
131      (void) benchmark_timer_empty_function();
132  overhead = benchmark_timer_read();
133
134  benchmark_timer_initialize();
135    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
136      (void) rtems_task_ident( index, RTEMS_SEARCH_ALL_NODES, &id );
137  end_time = benchmark_timer_read();
138
139  put_time(
140    "rtems_task_ident: only case",
141    end_time,
142    OPERATION_COUNT,
143    overhead,
144    CALLING_OVERHEAD_TASK_IDENT
145  );
146
147  benchmark_timer_initialize();
148    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
149      (void) rtems_message_queue_ident( index, RTEMS_SEARCH_ALL_NODES, &id );
150  end_time = benchmark_timer_read();
151
152  put_time(
153    "rtems_message_queue_ident: only case",
154    end_time,
155    OPERATION_COUNT,
156    overhead,
157    CALLING_OVERHEAD_MESSAGE_QUEUE_IDENT
158  );
159
160  benchmark_timer_initialize();
161    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
162      (void) rtems_semaphore_ident( index, RTEMS_SEARCH_ALL_NODES, &id );
163  end_time = benchmark_timer_read();
164
165  put_time(
166    "rtems_semaphore_ident: only case",
167    end_time,
168    OPERATION_COUNT,
169    overhead,
170    CALLING_OVERHEAD_SEMAPHORE_IDENT
171  );
172
173  benchmark_timer_initialize();
174    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
175      (void) rtems_partition_ident( index, RTEMS_SEARCH_ALL_NODES, &id );
176  end_time = benchmark_timer_read();
177
178  put_time(
179    "rtems_partition_ident: only case",
180    end_time,
181    OPERATION_COUNT,
182    overhead,
183    CALLING_OVERHEAD_PARTITION_IDENT
184  );
185
186  benchmark_timer_initialize();
187    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
188      (void) rtems_region_ident( index, &id );
189  end_time = benchmark_timer_read();
190
191  put_time(
192    "rtems_region_ident: only case",
193    end_time,
194    OPERATION_COUNT,
195    overhead,
196    CALLING_OVERHEAD_REGION_IDENT
197  );
198
199  benchmark_timer_initialize();
200    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
201      (void) rtems_port_ident( index, &id );
202  end_time = benchmark_timer_read();
203
204  put_time(
205    "rtems_port_ident: only case",
206    end_time,
207    OPERATION_COUNT,
208    overhead,
209    CALLING_OVERHEAD_PORT_IDENT
210  );
211
212  benchmark_timer_initialize();
213    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
214      (void) rtems_timer_ident( index, &id );
215  end_time = benchmark_timer_read();
216
217  put_time(
218    "rtems_timer_ident: only case",
219    end_time,
220    OPERATION_COUNT,
221    overhead,
222    CALLING_OVERHEAD_TIMER_IDENT
223  );
224
225  benchmark_timer_initialize();
226    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
227      (void) rtems_rate_monotonic_ident( index, &id );
228  end_time = benchmark_timer_read();
229
230  put_time(
231    "rtems_rate_monotonic_ident: only case",
232    end_time,
233    OPERATION_COUNT,
234    overhead,
235    CALLING_OVERHEAD_RATE_MONOTONIC_IDENT
236  );
237
238  TEST_END();
239  rtems_test_exit( 0 );
240}
Note: See TracBrowser for help on using the repository browser.