[ac7d5ef0] | 1 | /* |
---|
[9410d011] | 2 | * COPYRIGHT (c) 1989-2013. |
---|
[ac7d5ef0] | 3 | * On-Line Applications Research Corporation (OAR). |
---|
| 4 | * |
---|
[98e4ebf5] | 5 | * The license and distribution terms for this file may be |
---|
| 6 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 7 | * http://www.rtems.org/license/LICENSE. |
---|
[ac7d5ef0] | 8 | */ |
---|
| 9 | |
---|
[a4bc4d6e] | 10 | #ifdef HAVE_CONFIG_H |
---|
| 11 | #include "config.h" |
---|
| 12 | #endif |
---|
| 13 | |
---|
[d1128e2] | 14 | #define CONFIGURE_INIT |
---|
[ac7d5ef0] | 15 | #include "system.h" |
---|
| 16 | |
---|
| 17 | rtems_id Queue_id; |
---|
| 18 | long Buffer[4]; |
---|
| 19 | |
---|
| 20 | rtems_task High_task( |
---|
| 21 | rtems_task_argument argument |
---|
| 22 | ); |
---|
| 23 | |
---|
| 24 | rtems_task Middle_tasks( |
---|
| 25 | rtems_task_argument argument |
---|
| 26 | ); |
---|
| 27 | |
---|
| 28 | rtems_task Low_task( |
---|
| 29 | rtems_task_argument argument |
---|
| 30 | ); |
---|
| 31 | |
---|
[1055ce20] | 32 | void test_init(void); |
---|
[ac7d5ef0] | 33 | |
---|
[4389287a] | 34 | int operation_count = OPERATION_COUNT; |
---|
| 35 | |
---|
[ac7d5ef0] | 36 | rtems_task Init( |
---|
| 37 | rtems_task_argument argument |
---|
| 38 | ) |
---|
| 39 | { |
---|
| 40 | rtems_status_code status; |
---|
| 41 | |
---|
[3a4ae6c] | 42 | Print_Warning(); |
---|
| 43 | |
---|
[ac7d5ef0] | 44 | puts( "\n\n*** TIME TEST 10 ***" ); |
---|
| 45 | |
---|
| 46 | test_init(); |
---|
| 47 | |
---|
| 48 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 49 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | void test_init() |
---|
| 53 | { |
---|
[4389287a] | 54 | int index; |
---|
[5343588] | 55 | size_t size; |
---|
[ac7d5ef0] | 56 | rtems_task_entry task_entry; |
---|
| 57 | rtems_status_code status; |
---|
| 58 | rtems_task_priority priority; |
---|
| 59 | rtems_id task_id; |
---|
| 60 | |
---|
[4389287a] | 61 | priority = 2; |
---|
| 62 | |
---|
| 63 | if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 ) |
---|
| 64 | operation_count = RTEMS_MAXIMUM_PRIORITY - 2; |
---|
[ac7d5ef0] | 65 | |
---|
[4389287a] | 66 | for( index = 0; index < operation_count ; index++ ) { |
---|
[ac7d5ef0] | 67 | status = rtems_task_create( |
---|
| 68 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
| 69 | priority, |
---|
[3652ad35] | 70 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 71 | RTEMS_DEFAULT_MODES, |
---|
| 72 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 73 | &task_id |
---|
| 74 | ); |
---|
| 75 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
| 76 | |
---|
| 77 | priority++; |
---|
| 78 | |
---|
| 79 | if ( index==0 ) task_entry = High_task; |
---|
[4389287a] | 80 | else if ( index==operation_count-1 ) task_entry = Low_task; |
---|
[ac7d5ef0] | 81 | else task_entry = Middle_tasks; |
---|
| 82 | |
---|
| 83 | status = rtems_task_start( task_id, task_entry, 0 ); |
---|
| 84 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | status = rtems_message_queue_create( |
---|
| 88 | 1, |
---|
[1055ce20] | 89 | (uint32_t)operation_count, |
---|
[4b374f36] | 90 | 16, |
---|
[ac7d5ef0] | 91 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 92 | &Queue_id |
---|
| 93 | ); |
---|
| 94 | directive_failed( status, "rtems_message_queue_create" ); |
---|
| 95 | |
---|
[dbf4f17] | 96 | benchmark_timer_initialize(); |
---|
[4389287a] | 97 | for ( index=1 ; index < operation_count ; index++ ) |
---|
[dbf4f17] | 98 | (void) benchmark_timer_empty_function(); |
---|
| 99 | overhead = benchmark_timer_read(); |
---|
[ac7d5ef0] | 100 | |
---|
[dbf4f17] | 101 | benchmark_timer_initialize(); |
---|
[4389287a] | 102 | for ( index=1 ; index < operation_count ; index++ ) |
---|
[ac7d5ef0] | 103 | (void) rtems_message_queue_receive( |
---|
| 104 | Queue_id, |
---|
| 105 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 106 | &size, |
---|
[ac7d5ef0] | 107 | RTEMS_NO_WAIT, |
---|
| 108 | RTEMS_NO_TIMEOUT |
---|
| 109 | ); |
---|
[dbf4f17] | 110 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 111 | |
---|
| 112 | put_time( |
---|
[9410d011] | 113 | "rtems_message_queue_receive: not available NO_WAIT", |
---|
[ac7d5ef0] | 114 | end_time, |
---|
[4389287a] | 115 | operation_count, |
---|
[ac7d5ef0] | 116 | overhead, |
---|
| 117 | CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE |
---|
| 118 | ); |
---|
| 119 | |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | rtems_task High_task( |
---|
| 123 | rtems_task_argument argument |
---|
| 124 | ) |
---|
| 125 | { |
---|
[5343588] | 126 | size_t size; |
---|
[8f71a36] | 127 | |
---|
[dbf4f17] | 128 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 129 | (void) rtems_message_queue_receive( |
---|
| 130 | Queue_id, |
---|
| 131 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 132 | &size, |
---|
[ac7d5ef0] | 133 | RTEMS_DEFAULT_OPTIONS, |
---|
| 134 | RTEMS_NO_TIMEOUT |
---|
| 135 | ); |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | rtems_task Middle_tasks( |
---|
| 139 | rtems_task_argument argument |
---|
| 140 | ) |
---|
| 141 | { |
---|
[5343588] | 142 | size_t size; |
---|
[8f71a36] | 143 | |
---|
[ac7d5ef0] | 144 | (void) rtems_message_queue_receive( |
---|
| 145 | Queue_id, |
---|
| 146 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 147 | &size, |
---|
[ac7d5ef0] | 148 | RTEMS_DEFAULT_OPTIONS, |
---|
| 149 | RTEMS_NO_TIMEOUT |
---|
| 150 | ); |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | rtems_task Low_task( |
---|
| 155 | rtems_task_argument argument |
---|
| 156 | ) |
---|
| 157 | { |
---|
[dbf4f17] | 158 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 159 | |
---|
| 160 | put_time( |
---|
[9410d011] | 161 | "rtems_message_queue_receive: not available caller blocks", |
---|
[ac7d5ef0] | 162 | end_time, |
---|
[4389287a] | 163 | operation_count - 1, |
---|
[ac7d5ef0] | 164 | 0, |
---|
| 165 | CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE |
---|
| 166 | ); |
---|
| 167 | |
---|
[3a4ae6c] | 168 | puts( "*** END OF TEST 10 ***" ); |
---|
[b454bc9] | 169 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 170 | } |
---|