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