[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 Task_id[ OPERATION_COUNT + 1 ]; |
---|
| 18 | |
---|
[0720ff4] | 19 | uint32_t Task_restarted; |
---|
[ac7d5ef0] | 20 | |
---|
| 21 | rtems_task null_task( |
---|
| 22 | rtems_task_argument argument |
---|
| 23 | ); |
---|
| 24 | |
---|
| 25 | rtems_task Task_1( |
---|
| 26 | rtems_task_argument argument |
---|
| 27 | ); |
---|
| 28 | |
---|
| 29 | void test_init( void ); |
---|
| 30 | |
---|
| 31 | rtems_task Init( |
---|
| 32 | rtems_task_argument argument |
---|
| 33 | ) |
---|
| 34 | { |
---|
| 35 | rtems_status_code status; |
---|
| 36 | |
---|
[3a4ae6c] | 37 | Print_Warning(); |
---|
| 38 | |
---|
[ac7d5ef0] | 39 | puts( "\n\n*** TIME TEST 6 ***" ); |
---|
| 40 | |
---|
| 41 | test_init(); |
---|
| 42 | |
---|
| 43 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 44 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | void test_init( void ) |
---|
| 48 | { |
---|
| 49 | rtems_status_code status; |
---|
[1055ce20] | 50 | rtems_id id; |
---|
[ac7d5ef0] | 51 | |
---|
| 52 | Task_restarted = OPERATION_COUNT; |
---|
| 53 | |
---|
| 54 | status = rtems_task_create( |
---|
| 55 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
[1055ce20] | 56 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u, |
---|
[3652ad35] | 57 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 58 | RTEMS_DEFAULT_MODES, |
---|
| 59 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 60 | &id |
---|
| 61 | ); |
---|
| 62 | directive_failed( status, "rtems_task_create" ); |
---|
| 63 | |
---|
| 64 | status = rtems_task_start( id, Task_1, 0 ); |
---|
| 65 | directive_failed( status, "rtems_task_start" ); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | rtems_task Task_1( |
---|
| 69 | rtems_task_argument argument |
---|
| 70 | ) |
---|
| 71 | { |
---|
| 72 | rtems_status_code status; |
---|
[0720ff4] | 73 | uint32_t index; |
---|
[ac7d5ef0] | 74 | |
---|
| 75 | if ( Task_restarted == OPERATION_COUNT ) |
---|
[dbf4f17] | 76 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 77 | |
---|
| 78 | Task_restarted--; |
---|
| 79 | |
---|
| 80 | if ( Task_restarted != 0 ) |
---|
| 81 | (void) rtems_task_restart( RTEMS_SELF, 0 ); |
---|
| 82 | |
---|
[dbf4f17] | 83 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 84 | |
---|
[dbf4f17] | 85 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 86 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[dbf4f17] | 87 | (void) benchmark_timer_empty_function(); |
---|
| 88 | overhead = benchmark_timer_read(); |
---|
[ac7d5ef0] | 89 | |
---|
| 90 | put_time( |
---|
[5c491aef] | 91 | "rtems_task_restart: calling task", |
---|
[ac7d5ef0] | 92 | end_time, |
---|
| 93 | OPERATION_COUNT, |
---|
| 94 | overhead, |
---|
| 95 | CALLING_OVERHEAD_TASK_RESTART |
---|
| 96 | ); |
---|
| 97 | |
---|
| 98 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 99 | status = rtems_task_create( |
---|
| 100 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
[1055ce20] | 101 | RTEMS_MAXIMUM_PRIORITY - 1u, |
---|
[3652ad35] | 102 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 103 | RTEMS_DEFAULT_MODES, |
---|
| 104 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 105 | &Task_id[ index ] |
---|
| 106 | ); |
---|
| 107 | directive_failed( status, "rtems_task_create loop" ); |
---|
| 108 | |
---|
| 109 | status = rtems_task_start( Task_id[ index ], null_task, 0 ); |
---|
| 110 | directive_failed( status, "rtems_task_start loop" ); |
---|
| 111 | } |
---|
| 112 | |
---|
[dbf4f17] | 113 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 114 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 115 | (void) rtems_task_suspend( Task_id[ index ] ); |
---|
[dbf4f17] | 116 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 117 | |
---|
| 118 | put_time( |
---|
[5c491aef] | 119 | "rtems_task_suspend: returns to caller", |
---|
[ac7d5ef0] | 120 | end_time, |
---|
| 121 | OPERATION_COUNT, |
---|
| 122 | 0, |
---|
| 123 | CALLING_OVERHEAD_TASK_SUSPEND |
---|
| 124 | ); |
---|
| 125 | |
---|
[dbf4f17] | 126 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 127 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 128 | (void) rtems_task_resume( Task_id[ index ] ); |
---|
[dbf4f17] | 129 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 130 | |
---|
| 131 | put_time( |
---|
[9410d011] | 132 | "rtems_task_resume: task readied returns to caller", |
---|
[ac7d5ef0] | 133 | end_time, |
---|
| 134 | OPERATION_COUNT, |
---|
| 135 | 0, |
---|
| 136 | CALLING_OVERHEAD_TASK_RESUME |
---|
| 137 | ); |
---|
| 138 | |
---|
[dbf4f17] | 139 | benchmark_timer_initialize(); |
---|
[ac7d5ef0] | 140 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 141 | (void) rtems_task_delete( Task_id[ index ] ); |
---|
[dbf4f17] | 142 | end_time = benchmark_timer_read(); |
---|
[ac7d5ef0] | 143 | |
---|
| 144 | put_time( |
---|
[5c491aef] | 145 | "rtems_task_delete: ready task", |
---|
[ac7d5ef0] | 146 | end_time, |
---|
| 147 | OPERATION_COUNT, |
---|
| 148 | 0, |
---|
| 149 | CALLING_OVERHEAD_TASK_RESUME |
---|
| 150 | ); |
---|
| 151 | |
---|
[3a4ae6c] | 152 | puts( "*** END OF TEST 6 ***" ); |
---|
[b454bc9] | 153 | rtems_test_exit( 0 ); |
---|
[ac7d5ef0] | 154 | } |
---|
| 155 | |
---|
| 156 | rtems_task null_task( |
---|
| 157 | rtems_task_argument argument |
---|
| 158 | ) |
---|
| 159 | { |
---|
| 160 | while ( FOREVER ) |
---|
| 161 | ; |
---|
| 162 | } |
---|