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