[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 | * |
---|
[4b374f36] | 11 | * task1.c,v 1.2 1995/05/31 17:15:39 joel Exp |
---|
[ac7d5ef0] | 12 | */ |
---|
| 13 | |
---|
| 14 | #include "system.h" |
---|
| 15 | #undef EXTERN |
---|
| 16 | #define EXTERN |
---|
| 17 | #include "conftbl.h" |
---|
| 18 | #include "gvar.h" |
---|
| 19 | |
---|
| 20 | rtems_id Queue_id; |
---|
| 21 | long Buffer[4]; |
---|
| 22 | |
---|
| 23 | rtems_task High_task( |
---|
| 24 | rtems_task_argument argument |
---|
| 25 | ); |
---|
| 26 | |
---|
| 27 | rtems_task Middle_tasks( |
---|
| 28 | rtems_task_argument argument |
---|
| 29 | ); |
---|
| 30 | |
---|
| 31 | rtems_task Low_task( |
---|
| 32 | rtems_task_argument argument |
---|
| 33 | ); |
---|
| 34 | |
---|
| 35 | void test_init(); |
---|
| 36 | |
---|
| 37 | rtems_task Init( |
---|
| 38 | rtems_task_argument argument |
---|
| 39 | ) |
---|
| 40 | { |
---|
| 41 | rtems_status_code status; |
---|
| 42 | |
---|
| 43 | puts( "\n\n*** TIME TEST 10 ***" ); |
---|
| 44 | |
---|
| 45 | test_init(); |
---|
| 46 | |
---|
| 47 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 48 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | void test_init() |
---|
| 52 | { |
---|
| 53 | rtems_unsigned32 index; |
---|
[4b374f36] | 54 | rtems_unsigned32 size; |
---|
[ac7d5ef0] | 55 | rtems_task_entry task_entry; |
---|
| 56 | rtems_status_code status; |
---|
| 57 | rtems_task_priority priority; |
---|
| 58 | rtems_id task_id; |
---|
| 59 | |
---|
| 60 | priority = 5; |
---|
| 61 | |
---|
| 62 | for( index = 0; index <= OPERATION_COUNT ; index++ ) { |
---|
| 63 | status = rtems_task_create( |
---|
| 64 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
| 65 | priority, |
---|
| 66 | 1024, |
---|
| 67 | RTEMS_DEFAULT_MODES, |
---|
| 68 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 69 | &task_id |
---|
| 70 | ); |
---|
| 71 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
| 72 | |
---|
| 73 | priority++; |
---|
| 74 | |
---|
| 75 | if ( index==0 ) task_entry = High_task; |
---|
| 76 | else if ( index==OPERATION_COUNT ) task_entry = Low_task; |
---|
| 77 | else task_entry = Middle_tasks; |
---|
| 78 | |
---|
| 79 | status = rtems_task_start( task_id, task_entry, 0 ); |
---|
| 80 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | status = rtems_message_queue_create( |
---|
| 84 | 1, |
---|
| 85 | OPERATION_COUNT, |
---|
[4b374f36] | 86 | 16, |
---|
[ac7d5ef0] | 87 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 88 | &Queue_id |
---|
| 89 | ); |
---|
| 90 | directive_failed( status, "rtems_message_queue_create" ); |
---|
| 91 | |
---|
| 92 | Timer_initialize(); |
---|
| 93 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 94 | (void) Empty_function(); |
---|
| 95 | overhead = Read_timer(); |
---|
| 96 | |
---|
| 97 | Timer_initialize(); |
---|
| 98 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 99 | (void) rtems_message_queue_receive( |
---|
| 100 | Queue_id, |
---|
| 101 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 102 | &size, |
---|
[ac7d5ef0] | 103 | RTEMS_NO_WAIT, |
---|
| 104 | RTEMS_NO_TIMEOUT |
---|
| 105 | ); |
---|
| 106 | end_time = Read_timer(); |
---|
| 107 | |
---|
| 108 | put_time( |
---|
| 109 | "rtems_message_queue_receive (RTEMS_NO_WAIT)", |
---|
| 110 | end_time, |
---|
| 111 | OPERATION_COUNT, |
---|
| 112 | overhead, |
---|
| 113 | CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE |
---|
| 114 | ); |
---|
| 115 | |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | rtems_task High_task( |
---|
| 119 | rtems_task_argument argument |
---|
| 120 | ) |
---|
| 121 | { |
---|
[4b374f36] | 122 | rtems_unsigned32 size; |
---|
| 123 | |
---|
[ac7d5ef0] | 124 | Timer_initialize(); |
---|
| 125 | (void) rtems_message_queue_receive( |
---|
| 126 | Queue_id, |
---|
| 127 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 128 | &size, |
---|
[ac7d5ef0] | 129 | RTEMS_DEFAULT_OPTIONS, |
---|
| 130 | RTEMS_NO_TIMEOUT |
---|
| 131 | ); |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | rtems_task Middle_tasks( |
---|
| 135 | rtems_task_argument argument |
---|
| 136 | ) |
---|
| 137 | { |
---|
[4b374f36] | 138 | rtems_unsigned32 size; |
---|
| 139 | |
---|
[ac7d5ef0] | 140 | (void) rtems_message_queue_receive( |
---|
| 141 | Queue_id, |
---|
| 142 | (long (*)[4]) Buffer, |
---|
[4b374f36] | 143 | &size, |
---|
[ac7d5ef0] | 144 | RTEMS_DEFAULT_OPTIONS, |
---|
| 145 | RTEMS_NO_TIMEOUT |
---|
| 146 | ); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | rtems_task Low_task( |
---|
| 151 | rtems_task_argument argument |
---|
| 152 | ) |
---|
| 153 | { |
---|
| 154 | end_time = Read_timer(); |
---|
| 155 | |
---|
| 156 | put_time( |
---|
| 157 | "rtems_message_queue_receive (blocking)", |
---|
| 158 | end_time, |
---|
| 159 | OPERATION_COUNT, |
---|
| 160 | 0, |
---|
| 161 | CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE |
---|
| 162 | ); |
---|
| 163 | |
---|
| 164 | exit( 0 ); |
---|
| 165 | } |
---|