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