[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 High_id; |
---|
| 18 | rtems_id Low_id; |
---|
| 19 | rtems_id Semaphore_id; |
---|
| 20 | |
---|
| 21 | rtems_task High_task( |
---|
| 22 | rtems_task_argument argument |
---|
| 23 | ); |
---|
| 24 | |
---|
| 25 | rtems_task Middle_tasks( |
---|
| 26 | rtems_task_argument argument |
---|
| 27 | ); |
---|
| 28 | |
---|
| 29 | rtems_task Low_task( |
---|
| 30 | rtems_task_argument argument |
---|
| 31 | ); |
---|
| 32 | |
---|
[4389287a] | 33 | int operation_count = OPERATION_COUNT; |
---|
[ac7d5ef0] | 34 | |
---|
[1055ce20] | 35 | void test_init(void); |
---|
[ac7d5ef0] | 36 | |
---|
| 37 | rtems_task Init( |
---|
| 38 | rtems_task_argument argument |
---|
| 39 | ) |
---|
| 40 | { |
---|
| 41 | rtems_status_code status; |
---|
| 42 | |
---|
[3a4ae6c] | 43 | Print_Warning(); |
---|
| 44 | |
---|
[ac7d5ef0] | 45 | puts( "\n\n*** TIME TEST 2 ***" ); |
---|
| 46 | |
---|
| 47 | test_init(); |
---|
| 48 | |
---|
| 49 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 50 | directive_failed( status, "rtems_task_delete" ); |
---|
| 51 | } |
---|
| 52 | |
---|
[1055ce20] | 53 | void test_init(void) |
---|
[ac7d5ef0] | 54 | { |
---|
| 55 | rtems_status_code status; |
---|
[1055ce20] | 56 | int index; |
---|
[ac7d5ef0] | 57 | rtems_task_priority priority; |
---|
| 58 | |
---|
[4389287a] | 59 | priority = 2; |
---|
[ac7d5ef0] | 60 | |
---|
| 61 | status = rtems_task_create( |
---|
| 62 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
| 63 | priority, |
---|
[3652ad35] | 64 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 65 | RTEMS_DEFAULT_MODES, |
---|
| 66 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 67 | &High_id |
---|
| 68 | ); |
---|
| 69 | directive_failed( status, "rtems_task_create of high task" ); |
---|
| 70 | |
---|
| 71 | priority++; |
---|
| 72 | |
---|
| 73 | status = rtems_task_start( High_id, High_task, 0 ); |
---|
| 74 | directive_failed( status, "rtems_task_start of high task" ); |
---|
| 75 | |
---|
[1055ce20] | 76 | if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u ) |
---|
| 77 | operation_count = (int) (RTEMS_MAXIMUM_PRIORITY - 2u); |
---|
[4389287a] | 78 | for ( index=2 ; index < operation_count ; index++ ) { |
---|
[ac7d5ef0] | 79 | status = rtems_task_create( |
---|
| 80 | rtems_build_name( 'M', 'I', 'D', ' ' ), |
---|
| 81 | priority, |
---|
[3652ad35] | 82 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 83 | RTEMS_DEFAULT_MODES, |
---|
| 84 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 85 | &Low_id |
---|
| 86 | ); |
---|
| 87 | directive_failed( status, "rtems_task_create middle" ); |
---|
| 88 | |
---|
| 89 | priority++; |
---|
| 90 | |
---|
| 91 | status = rtems_task_start( Low_id, Middle_tasks, 0 ); |
---|
| 92 | directive_failed( status, "rtems_task_start middle" ); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | status = rtems_task_create( |
---|
| 96 | rtems_build_name( 'L', 'O', 'W', ' ' ), |
---|
| 97 | priority, |
---|
[3652ad35] | 98 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 99 | RTEMS_DEFAULT_MODES, |
---|
| 100 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 101 | &Low_id |
---|
| 102 | ); |
---|
| 103 | directive_failed( status, "rtems_task_create low" ); |
---|
| 104 | |
---|
| 105 | status = rtems_task_start( Low_id, Low_task, 0 ); |
---|
| 106 | directive_failed( status, "rtems_task_start low" ); |
---|
| 107 | |
---|
| 108 | status = rtems_semaphore_create( |
---|
| 109 | rtems_build_name( 'S', 'M', '1', ' '), |
---|
| 110 | 0, |
---|
| 111 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
[7f6a24ab] | 112 | RTEMS_NO_PRIORITY, |
---|
[ac7d5ef0] | 113 | &Semaphore_id |
---|
| 114 | ); |
---|
| 115 | directive_failed( status, "rtems_semaphore_create of SM1" ); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | rtems_task High_task( |
---|
| 119 | rtems_task_argument argument |
---|
| 120 | ) |
---|
| 121 | { |
---|
[3f42f12c] | 122 | /* start blocking rtems_semaphore_obtain time */ |
---|
| 123 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 124 | |
---|
[3f42f12c] | 125 | (void) rtems_semaphore_obtain( |
---|
[ac7d5ef0] | 126 | Semaphore_id, |
---|
| 127 | RTEMS_DEFAULT_OPTIONS, |
---|
| 128 | RTEMS_NO_TIMEOUT |
---|
| 129 | ); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | rtems_task Middle_tasks( |
---|
| 133 | rtems_task_argument argument |
---|
| 134 | ) |
---|
| 135 | { |
---|
[3f42f12c] | 136 | (void) rtems_semaphore_obtain( |
---|
[ac7d5ef0] | 137 | Semaphore_id, |
---|
| 138 | RTEMS_DEFAULT_OPTIONS, |
---|
| 139 | RTEMS_NO_TIMEOUT |
---|
| 140 | ); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | rtems_task Low_task( |
---|
| 144 | rtems_task_argument argument |
---|
| 145 | ) |
---|
| 146 | { |
---|
[dbf4f17] | 147 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 148 | |
---|
| 149 | put_time( |
---|
[9410d011] | 150 | "rtems_semaphore_obtain: not available caller blocks", |
---|
[ac7d5ef0] | 151 | end_time, |
---|
[4389287a] | 152 | operation_count - 1, |
---|
[ac7d5ef0] | 153 | 0, |
---|
| 154 | CALLING_OVERHEAD_SEMAPHORE_OBTAIN |
---|
| 155 | ); |
---|
[3a4ae6c] | 156 | |
---|
| 157 | puts( "*** END OF TEST 2 ***" ); |
---|
[b454bc9] | 158 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 159 | } |
---|