[ac7d5ef0] | 1 | /* |
---|
| 2 | * |
---|
| 3 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 4 | * On-Line Applications Research Corporation (OAR). |
---|
| 5 | * All rights assigned to U.S. Government, 1994. |
---|
| 6 | * |
---|
| 7 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 8 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 9 | * notice must appear in all copies of this file and its derivatives. |
---|
| 10 | * |
---|
[3235ad9] | 11 | * $Id$ |
---|
[ac7d5ef0] | 12 | */ |
---|
| 13 | |
---|
[3a4ae6c] | 14 | #define TEST_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 Middle_tasks( |
---|
| 26 | rtems_task_argument argument |
---|
| 27 | ); |
---|
| 28 | |
---|
| 29 | rtems_task High_task( |
---|
| 30 | rtems_task_argument argument |
---|
| 31 | ); |
---|
| 32 | |
---|
| 33 | void Init( |
---|
| 34 | rtems_task_argument argument |
---|
| 35 | ) |
---|
| 36 | { |
---|
| 37 | rtems_status_code status; |
---|
| 38 | rtems_id id; |
---|
| 39 | |
---|
[3a4ae6c] | 40 | Print_Warning(); |
---|
| 41 | |
---|
[ac7d5ef0] | 42 | puts( "\n\n*** TIME TEST 13 ***" ); |
---|
| 43 | |
---|
| 44 | status = rtems_task_create( |
---|
| 45 | 1, |
---|
| 46 | 251, |
---|
[3652ad35] | 47 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 48 | RTEMS_DEFAULT_MODES, |
---|
| 49 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 50 | &id |
---|
| 51 | ); |
---|
| 52 | directive_failed( status, "rtems_task_create" ); |
---|
| 53 | |
---|
| 54 | status = rtems_task_start( id, test_init, 0 ); |
---|
| 55 | directive_failed( status, "rtems_task_start" ); |
---|
| 56 | |
---|
| 57 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 58 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | rtems_task test_init( |
---|
| 62 | rtems_task_argument argument |
---|
| 63 | ) |
---|
| 64 | { |
---|
| 65 | rtems_unsigned32 index; |
---|
| 66 | rtems_task_entry task_entry; |
---|
| 67 | rtems_task_priority priority; |
---|
| 68 | rtems_id task_id; |
---|
| 69 | rtems_status_code status; |
---|
| 70 | |
---|
| 71 | /* As each task is started, it preempts this task and |
---|
| 72 | * performs a blocking rtems_message_queue_receive. Upon completion of |
---|
| 73 | * this loop all created tasks are blocked. |
---|
| 74 | */ |
---|
| 75 | |
---|
| 76 | status = rtems_message_queue_create( |
---|
| 77 | rtems_build_name( 'M', 'Q', '1', ' ' ), |
---|
| 78 | OPERATION_COUNT, |
---|
[4b374f36] | 79 | 16, |
---|
[ac7d5ef0] | 80 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 81 | &Queue_id |
---|
| 82 | ); |
---|
| 83 | directive_failed( status, "rtems_message_queue_create" ); |
---|
| 84 | |
---|
| 85 | priority = 250; |
---|
| 86 | |
---|
| 87 | for( index = 0; index < OPERATION_COUNT ; index++ ) { |
---|
| 88 | status = rtems_task_create( |
---|
| 89 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
| 90 | priority, |
---|
[3652ad35] | 91 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 92 | RTEMS_DEFAULT_MODES, |
---|
| 93 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 94 | &task_id |
---|
| 95 | ); |
---|
| 96 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
| 97 | |
---|
| 98 | priority--; |
---|
| 99 | |
---|
| 100 | if ( index==OPERATION_COUNT-1 ) task_entry = High_task; |
---|
| 101 | else task_entry = Middle_tasks; |
---|
| 102 | |
---|
| 103 | status = rtems_task_start( task_id, task_entry, 0 ); |
---|
| 104 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | Timer_initialize(); |
---|
[4b374f36] | 108 | (void) rtems_message_queue_urgent( Queue_id, (long (*)[4]) Buffer, 16 ); |
---|
[ac7d5ef0] | 109 | } |
---|
| 110 | |
---|
| 111 | rtems_task Middle_tasks( |
---|
| 112 | rtems_task_argument argument |
---|
| 113 | ) |
---|
| 114 | { |
---|
[4b374f36] | 115 | rtems_unsigned32 size; |
---|
| 116 | |
---|
[ac7d5ef0] | 117 | (void) rtems_message_queue_receive( |
---|
| 118 | Queue_id, |
---|
| 119 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 120 | &size, |
---|
[ac7d5ef0] | 121 | RTEMS_DEFAULT_OPTIONS, |
---|
| 122 | RTEMS_NO_TIMEOUT |
---|
| 123 | ); |
---|
| 124 | |
---|
[4b374f36] | 125 | (void) rtems_message_queue_urgent( Queue_id, (long (*)[4]) Buffer, size ); |
---|
[ac7d5ef0] | 126 | } |
---|
| 127 | |
---|
| 128 | rtems_task High_task( |
---|
| 129 | rtems_task_argument argument |
---|
| 130 | ) |
---|
| 131 | { |
---|
[4b374f36] | 132 | rtems_unsigned32 size; |
---|
| 133 | |
---|
[ac7d5ef0] | 134 | (void) rtems_message_queue_receive( |
---|
| 135 | Queue_id, |
---|
| 136 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 137 | &size, |
---|
[ac7d5ef0] | 138 | RTEMS_DEFAULT_OPTIONS, |
---|
| 139 | RTEMS_NO_TIMEOUT |
---|
| 140 | ); |
---|
| 141 | |
---|
| 142 | end_time = Read_timer(); |
---|
| 143 | |
---|
| 144 | put_time( |
---|
| 145 | "rtems_message_queue_urgent (preemptive)", |
---|
| 146 | end_time, |
---|
| 147 | OPERATION_COUNT, |
---|
| 148 | 0, |
---|
| 149 | CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT |
---|
| 150 | ); |
---|
| 151 | |
---|
[3a4ae6c] | 152 | puts( "*** END OF TEST 13 ***" ); |
---|
[ac7d5ef0] | 153 | exit( 0 ); |
---|
| 154 | } |
---|