[ac7d5ef0] | 1 | /* |
---|
| 2 | * |
---|
[08311cc3] | 3 | * COPYRIGHT (c) 1989-1999. |
---|
[ac7d5ef0] | 4 | * On-Line Applications Research Corporation (OAR). |
---|
| 5 | * |
---|
[98e4ebf5] | 6 | * The license and distribution terms for this file may be |
---|
| 7 | * found in the file LICENSE in this distribution or at |
---|
[95a81ab] | 8 | * http://www.rtems.com/license/LICENSE. |
---|
[ac7d5ef0] | 9 | * |
---|
[3235ad9] | 10 | * $Id$ |
---|
[ac7d5ef0] | 11 | */ |
---|
| 12 | |
---|
[3a4ae6c] | 13 | #define TEST_INIT |
---|
[ac7d5ef0] | 14 | #include "system.h" |
---|
| 15 | |
---|
| 16 | rtems_id Queue_id; |
---|
| 17 | |
---|
| 18 | long Buffer[4]; |
---|
| 19 | |
---|
| 20 | rtems_task Low_task( |
---|
| 21 | rtems_task_argument argument |
---|
| 22 | ); |
---|
| 23 | |
---|
| 24 | rtems_task High_task( |
---|
| 25 | rtems_task_argument argument |
---|
| 26 | ); |
---|
| 27 | |
---|
| 28 | rtems_task Preempt_task( |
---|
| 29 | rtems_task_argument argument |
---|
| 30 | ); |
---|
| 31 | |
---|
[df49c60] | 32 | #define MESSAGE_SIZE (sizeof(long) * 4) |
---|
| 33 | |
---|
[ac7d5ef0] | 34 | rtems_task Init( |
---|
| 35 | rtems_task_argument argument |
---|
| 36 | ) |
---|
| 37 | { |
---|
| 38 | rtems_id id; |
---|
| 39 | rtems_status_code status; |
---|
| 40 | |
---|
[3a4ae6c] | 41 | Print_Warning(); |
---|
| 42 | |
---|
[ac7d5ef0] | 43 | puts( "\n\n*** TIME TEST 22 ***" ); |
---|
| 44 | |
---|
| 45 | status = rtems_message_queue_create( |
---|
| 46 | rtems_build_name( 'M', 'Q', '1', ' '), |
---|
[4b374f36] | 47 | 100, |
---|
[df49c60] | 48 | MESSAGE_SIZE, |
---|
[ac7d5ef0] | 49 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 50 | &Queue_id |
---|
| 51 | ); |
---|
| 52 | directive_failed( status, "rtems_message_queue_create" ); |
---|
| 53 | |
---|
| 54 | status = rtems_task_create( |
---|
| 55 | rtems_build_name( 'L', 'O', 'W', ' ' ), |
---|
| 56 | 10, |
---|
[3652ad35] | 57 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 58 | RTEMS_NO_PREEMPT, |
---|
| 59 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 60 | &id |
---|
| 61 | ); |
---|
| 62 | directive_failed( status, "rtems_task_create" ); |
---|
| 63 | |
---|
| 64 | status = rtems_task_start( id, Low_task, 0 ); |
---|
| 65 | directive_failed( status, "rtems_task_start LOW" ); |
---|
| 66 | |
---|
| 67 | status = rtems_task_create( |
---|
| 68 | 1, |
---|
| 69 | 11, |
---|
[3652ad35] | 70 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 71 | RTEMS_DEFAULT_MODES, |
---|
| 72 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 73 | &id |
---|
| 74 | ); |
---|
| 75 | directive_failed( status, "rtems_task_create RTEMS_PREEMPT" ); |
---|
| 76 | |
---|
| 77 | status = rtems_task_start( id, Preempt_task, 0 ); |
---|
| 78 | directive_failed( status, "rtems_task_start RTEMS_PREEMPT" ); |
---|
| 79 | |
---|
| 80 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 81 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | rtems_task High_task( |
---|
| 85 | rtems_task_argument argument |
---|
| 86 | ) |
---|
| 87 | { |
---|
[0720ff4] | 88 | uint32_t count; |
---|
[ac7d5ef0] | 89 | rtems_status_code status; |
---|
| 90 | |
---|
| 91 | Timer_initialize(); |
---|
| 92 | (void) rtems_message_queue_broadcast( |
---|
| 93 | Queue_id, |
---|
[df49c60] | 94 | Buffer, |
---|
| 95 | MESSAGE_SIZE, |
---|
[ac7d5ef0] | 96 | &count |
---|
| 97 | ); |
---|
| 98 | end_time = Read_timer(); |
---|
| 99 | |
---|
| 100 | put_time( |
---|
[5c491aef] | 101 | "rtems_message_queue_broadcast: task readied -- returns to caller", |
---|
[ac7d5ef0] | 102 | end_time, |
---|
| 103 | 1, |
---|
| 104 | 0, |
---|
| 105 | CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST |
---|
| 106 | ); |
---|
| 107 | |
---|
| 108 | status = rtems_task_suspend(RTEMS_SELF); |
---|
| 109 | directive_failed( status, "rtems_task_suspend" ); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | rtems_task Low_task( |
---|
| 113 | rtems_task_argument argument |
---|
| 114 | ) |
---|
| 115 | { |
---|
| 116 | rtems_id id; |
---|
[0720ff4] | 117 | uint32_t index; |
---|
| 118 | uint32_t count; |
---|
| 119 | uint32_t size; |
---|
[ac7d5ef0] | 120 | rtems_status_code status; |
---|
| 121 | |
---|
| 122 | status = rtems_task_create( |
---|
| 123 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
| 124 | 5, |
---|
[3652ad35] | 125 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 126 | RTEMS_NO_PREEMPT, |
---|
| 127 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 128 | &id |
---|
| 129 | ); |
---|
| 130 | directive_failed( status, "rtems_task_create" ); |
---|
| 131 | |
---|
| 132 | status = rtems_task_start( id, High_task, 0 ); |
---|
| 133 | directive_failed( status, "rtems_task_start HIGH" ); |
---|
| 134 | |
---|
| 135 | status = rtems_message_queue_receive( |
---|
| 136 | Queue_id, |
---|
| 137 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 138 | &size, |
---|
[ac7d5ef0] | 139 | RTEMS_DEFAULT_OPTIONS, |
---|
| 140 | RTEMS_NO_TIMEOUT |
---|
| 141 | ); |
---|
| 142 | directive_failed( status, "message_queu_receive" ); |
---|
| 143 | |
---|
| 144 | Timer_initialize(); |
---|
| 145 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 146 | (void) rtems_message_queue_broadcast( |
---|
| 147 | Queue_id, |
---|
[df49c60] | 148 | Buffer, |
---|
| 149 | MESSAGE_SIZE, |
---|
[ac7d5ef0] | 150 | &count |
---|
| 151 | ); |
---|
| 152 | end_time = Read_timer(); |
---|
| 153 | |
---|
| 154 | put_time( |
---|
[5c491aef] | 155 | "rtems_message_queue_broadcast: no waiting tasks", |
---|
[ac7d5ef0] | 156 | end_time, |
---|
| 157 | OPERATION_COUNT, |
---|
| 158 | 1, |
---|
| 159 | CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST |
---|
| 160 | ); |
---|
| 161 | |
---|
| 162 | (void) rtems_message_queue_receive( |
---|
| 163 | Queue_id, |
---|
| 164 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 165 | &size, |
---|
[ac7d5ef0] | 166 | RTEMS_DEFAULT_OPTIONS, |
---|
| 167 | RTEMS_NO_TIMEOUT |
---|
| 168 | ); |
---|
| 169 | |
---|
| 170 | /* should go to Preempt_task here */ |
---|
| 171 | |
---|
| 172 | end_time = Read_timer(); |
---|
| 173 | |
---|
| 174 | put_time( |
---|
[5c491aef] | 175 | "rtems_message_queue_broadcast: task readied -- preempts caller", |
---|
[ac7d5ef0] | 176 | end_time, |
---|
| 177 | 1, |
---|
| 178 | 0, |
---|
| 179 | CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST |
---|
| 180 | ); |
---|
| 181 | |
---|
[3a4ae6c] | 182 | puts( "*** END OF TEST 22 ***" ); |
---|
[b454bc9] | 183 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 184 | } |
---|
| 185 | |
---|
| 186 | rtems_task Preempt_task( |
---|
| 187 | rtems_task_argument argument |
---|
| 188 | ) |
---|
| 189 | { |
---|
[0720ff4] | 190 | uint32_t count; |
---|
[ac7d5ef0] | 191 | |
---|
| 192 | Timer_initialize(); |
---|
| 193 | (void) rtems_message_queue_broadcast( |
---|
| 194 | Queue_id, |
---|
[df49c60] | 195 | Buffer, |
---|
| 196 | MESSAGE_SIZE, |
---|
[ac7d5ef0] | 197 | &count |
---|
| 198 | ); |
---|
| 199 | |
---|
| 200 | /* should be preempted by low task */ |
---|
| 201 | } |
---|