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 10"; |
---|
18 | |
---|
19 | rtems_id Queue_id; |
---|
20 | long Buffer[4]; |
---|
21 | |
---|
22 | rtems_task High_task( |
---|
23 | rtems_task_argument argument |
---|
24 | ); |
---|
25 | |
---|
26 | rtems_task Middle_tasks( |
---|
27 | rtems_task_argument argument |
---|
28 | ); |
---|
29 | |
---|
30 | rtems_task Low_task( |
---|
31 | rtems_task_argument argument |
---|
32 | ); |
---|
33 | |
---|
34 | void test_init(void); |
---|
35 | |
---|
36 | int operation_count = OPERATION_COUNT; |
---|
37 | |
---|
38 | rtems_task Init( |
---|
39 | rtems_task_argument argument |
---|
40 | ) |
---|
41 | { |
---|
42 | rtems_status_code status; |
---|
43 | |
---|
44 | Print_Warning(); |
---|
45 | |
---|
46 | TEST_BEGIN(); |
---|
47 | |
---|
48 | test_init(); |
---|
49 | |
---|
50 | status = rtems_task_delete( RTEMS_SELF ); |
---|
51 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
52 | } |
---|
53 | |
---|
54 | void test_init() |
---|
55 | { |
---|
56 | int index; |
---|
57 | size_t size; |
---|
58 | rtems_task_entry task_entry; |
---|
59 | rtems_status_code status; |
---|
60 | rtems_task_priority priority; |
---|
61 | rtems_id task_id; |
---|
62 | |
---|
63 | priority = 2; |
---|
64 | |
---|
65 | if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 ) |
---|
66 | operation_count = RTEMS_MAXIMUM_PRIORITY - 2; |
---|
67 | |
---|
68 | for( index = 0; index < operation_count ; index++ ) { |
---|
69 | status = rtems_task_create( |
---|
70 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
71 | priority, |
---|
72 | RTEMS_MINIMUM_STACK_SIZE, |
---|
73 | RTEMS_DEFAULT_MODES, |
---|
74 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
75 | &task_id |
---|
76 | ); |
---|
77 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
78 | |
---|
79 | priority++; |
---|
80 | |
---|
81 | if ( index==0 ) task_entry = High_task; |
---|
82 | else if ( index==operation_count-1 ) task_entry = Low_task; |
---|
83 | else task_entry = Middle_tasks; |
---|
84 | |
---|
85 | status = rtems_task_start( task_id, task_entry, 0 ); |
---|
86 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
87 | } |
---|
88 | |
---|
89 | status = rtems_message_queue_create( |
---|
90 | 1, |
---|
91 | (uint32_t)operation_count, |
---|
92 | 16, |
---|
93 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
94 | &Queue_id |
---|
95 | ); |
---|
96 | directive_failed( status, "rtems_message_queue_create" ); |
---|
97 | |
---|
98 | benchmark_timer_initialize(); |
---|
99 | for ( index=1 ; index < operation_count ; index++ ) |
---|
100 | (void) benchmark_timer_empty_function(); |
---|
101 | overhead = benchmark_timer_read(); |
---|
102 | |
---|
103 | benchmark_timer_initialize(); |
---|
104 | for ( index=1 ; index < operation_count ; index++ ) |
---|
105 | (void) rtems_message_queue_receive( |
---|
106 | Queue_id, |
---|
107 | (long (*)[4]) Buffer, |
---|
108 | &size, |
---|
109 | RTEMS_NO_WAIT, |
---|
110 | RTEMS_NO_TIMEOUT |
---|
111 | ); |
---|
112 | end_time = benchmark_timer_read(); |
---|
113 | |
---|
114 | put_time( |
---|
115 | "rtems_message_queue_receive: not available NO_WAIT", |
---|
116 | end_time, |
---|
117 | operation_count, |
---|
118 | overhead, |
---|
119 | CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE |
---|
120 | ); |
---|
121 | |
---|
122 | } |
---|
123 | |
---|
124 | rtems_task High_task( |
---|
125 | rtems_task_argument argument |
---|
126 | ) |
---|
127 | { |
---|
128 | size_t size; |
---|
129 | |
---|
130 | benchmark_timer_initialize(); |
---|
131 | (void) rtems_message_queue_receive( |
---|
132 | Queue_id, |
---|
133 | (long (*)[4]) Buffer, |
---|
134 | &size, |
---|
135 | RTEMS_DEFAULT_OPTIONS, |
---|
136 | RTEMS_NO_TIMEOUT |
---|
137 | ); |
---|
138 | } |
---|
139 | |
---|
140 | rtems_task Middle_tasks( |
---|
141 | rtems_task_argument argument |
---|
142 | ) |
---|
143 | { |
---|
144 | size_t size; |
---|
145 | |
---|
146 | (void) rtems_message_queue_receive( |
---|
147 | Queue_id, |
---|
148 | (long (*)[4]) Buffer, |
---|
149 | &size, |
---|
150 | RTEMS_DEFAULT_OPTIONS, |
---|
151 | RTEMS_NO_TIMEOUT |
---|
152 | ); |
---|
153 | } |
---|
154 | |
---|
155 | |
---|
156 | rtems_task Low_task( |
---|
157 | rtems_task_argument argument |
---|
158 | ) |
---|
159 | { |
---|
160 | end_time = benchmark_timer_read(); |
---|
161 | |
---|
162 | put_time( |
---|
163 | "rtems_message_queue_receive: not available caller blocks", |
---|
164 | end_time, |
---|
165 | operation_count - 1, |
---|
166 | 0, |
---|
167 | CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE |
---|
168 | ); |
---|
169 | |
---|
170 | TEST_END(); |
---|
171 | rtems_test_exit( 0 ); |
---|
172 | } |
---|