[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 | |
---|
[3a4ae6c] | 17 | rtems_device_major_number _STUB_major = 1; |
---|
[ac7d5ef0] | 18 | |
---|
| 19 | rtems_id Region_id; |
---|
| 20 | rtems_name Region_name; |
---|
| 21 | rtems_unsigned8 Region_area[ 2048 ] CPU_STRUCTURE_ALIGNMENT; |
---|
| 22 | |
---|
| 23 | rtems_id Partition_id; |
---|
| 24 | rtems_name Partition_name; |
---|
| 25 | rtems_unsigned8 Partition_area[ 2048 ] CPU_STRUCTURE_ALIGNMENT; |
---|
| 26 | |
---|
| 27 | void *Buffer_address_1; |
---|
| 28 | void *Buffer_address_2; |
---|
| 29 | void *Buffer_address_3; |
---|
| 30 | void *Buffer_address_4; |
---|
| 31 | |
---|
| 32 | rtems_unsigned32 buffer_count; |
---|
| 33 | |
---|
| 34 | void *Buffer_addresses[ OPERATION_COUNT+1 ]; |
---|
| 35 | |
---|
| 36 | rtems_task Task_1( |
---|
| 37 | rtems_task_argument argument |
---|
| 38 | ); |
---|
| 39 | |
---|
| 40 | rtems_task Task_2( |
---|
| 41 | rtems_task_argument argument |
---|
| 42 | ); |
---|
| 43 | |
---|
| 44 | rtems_task Init( |
---|
| 45 | rtems_task_argument argument |
---|
| 46 | ) |
---|
| 47 | { |
---|
| 48 | rtems_status_code status; |
---|
| 49 | |
---|
[3a4ae6c] | 50 | Print_Warning(); |
---|
| 51 | |
---|
[ac7d5ef0] | 52 | puts( "\n\n*** TIME TEST 20 ***" ); |
---|
| 53 | |
---|
| 54 | status = rtems_task_create( |
---|
| 55 | rtems_build_name( 'T', 'I', 'M', '1' ), |
---|
| 56 | 128, |
---|
[3652ad35] | 57 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 58 | RTEMS_DEFAULT_MODES, |
---|
| 59 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 60 | &Task_id[ 1 ] |
---|
| 61 | ); |
---|
| 62 | directive_failed( status, "rtems_task_create of TASK1" ); |
---|
| 63 | |
---|
| 64 | status = rtems_task_start( Task_id[ 1 ], Task_1, 0 ); |
---|
| 65 | directive_failed( status, "rtems_task_start of TASK1" ); |
---|
| 66 | |
---|
| 67 | status = rtems_task_create( |
---|
| 68 | rtems_build_name( 'T', 'I', 'M', '2' ), |
---|
| 69 | 129, |
---|
[3652ad35] | 70 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 71 | RTEMS_DEFAULT_MODES, |
---|
| 72 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 73 | &Task_id[ 2 ] |
---|
| 74 | ); |
---|
| 75 | directive_failed( status, "rtems_task_create of TASK2" ); |
---|
| 76 | |
---|
| 77 | status = rtems_task_start( Task_id[ 2 ], Task_2, 0 ); |
---|
| 78 | directive_failed( status, "rtems_task_start of TASK2" ); |
---|
| 79 | |
---|
| 80 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 81 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | rtems_task Task_1( |
---|
| 85 | rtems_task_argument argument |
---|
| 86 | ) |
---|
| 87 | { |
---|
| 88 | rtems_unsigned32 index; |
---|
| 89 | rtems_mode previous_mode; |
---|
| 90 | rtems_task_priority previous_priority; |
---|
| 91 | rtems_status_code status; |
---|
| 92 | |
---|
| 93 | Partition_name = rtems_build_name( 'P', 'A', 'R', 'T' ); |
---|
| 94 | |
---|
| 95 | Timer_initialize(); |
---|
| 96 | rtems_partition_create( |
---|
| 97 | Partition_name, |
---|
| 98 | Partition_area, |
---|
| 99 | 2048, |
---|
| 100 | 128, |
---|
| 101 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 102 | &Partition_id |
---|
| 103 | ); |
---|
| 104 | end_time = Read_timer(); |
---|
| 105 | |
---|
| 106 | put_time( |
---|
| 107 | "rtems_partition_create", |
---|
| 108 | end_time, |
---|
| 109 | 1, |
---|
| 110 | 0, |
---|
| 111 | CALLING_OVERHEAD_PARTITION_CREATE |
---|
| 112 | ); |
---|
| 113 | |
---|
| 114 | Region_name = rtems_build_name( 'R', 'E', 'G', 'N' ); |
---|
| 115 | |
---|
| 116 | Timer_initialize(); |
---|
| 117 | rtems_region_create( |
---|
| 118 | Region_name, |
---|
| 119 | Region_area, |
---|
| 120 | 2048, |
---|
| 121 | 16, |
---|
| 122 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 123 | &Region_id |
---|
| 124 | ); |
---|
| 125 | end_time = Read_timer(); |
---|
| 126 | |
---|
| 127 | put_time( |
---|
| 128 | "rtems_region_create", |
---|
| 129 | end_time, |
---|
| 130 | 1, |
---|
| 131 | 0, |
---|
| 132 | CALLING_OVERHEAD_REGION_CREATE |
---|
| 133 | ); |
---|
| 134 | |
---|
| 135 | Timer_initialize(); |
---|
| 136 | (void) rtems_partition_get_buffer( Partition_id, &Buffer_address_1 ); |
---|
| 137 | end_time = Read_timer(); |
---|
| 138 | |
---|
| 139 | put_time( |
---|
[5c491aef] | 140 | "rtems_partition_get_buffer: available", |
---|
[ac7d5ef0] | 141 | end_time, |
---|
| 142 | 1, |
---|
| 143 | 0, |
---|
| 144 | CALLING_OVERHEAD_PARTITION_GET_BUFFER |
---|
| 145 | ); |
---|
| 146 | |
---|
| 147 | buffer_count = 0; |
---|
| 148 | while ( FOREVER ) { |
---|
| 149 | |
---|
| 150 | status = rtems_partition_get_buffer( |
---|
| 151 | Partition_id, |
---|
| 152 | &Buffer_addresses[ buffer_count ] |
---|
| 153 | ); |
---|
| 154 | |
---|
| 155 | if ( status == RTEMS_UNSATISFIED ) break; |
---|
| 156 | |
---|
| 157 | buffer_count++; |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | Timer_initialize(); |
---|
| 161 | (void) rtems_partition_get_buffer( Partition_id, &Buffer_address_2 ); |
---|
| 162 | end_time = Read_timer(); |
---|
| 163 | |
---|
| 164 | put_time( |
---|
[5c491aef] | 165 | "rtems_partition_get_buffer: not available", |
---|
[ac7d5ef0] | 166 | end_time, |
---|
| 167 | 1, |
---|
| 168 | 0, |
---|
| 169 | CALLING_OVERHEAD_PARTITION_GET_BUFFER |
---|
| 170 | ); |
---|
| 171 | |
---|
| 172 | Timer_initialize(); |
---|
| 173 | (void) rtems_partition_return_buffer( Partition_id, Buffer_address_1 ); |
---|
| 174 | end_time = Read_timer(); |
---|
| 175 | |
---|
| 176 | put_time( |
---|
| 177 | "rtems_partition_return_buffer", |
---|
| 178 | end_time, |
---|
| 179 | 1, |
---|
| 180 | 0, |
---|
| 181 | CALLING_OVERHEAD_PARTITION_RETURN_BUFFER |
---|
| 182 | ); |
---|
| 183 | |
---|
| 184 | for ( index = 0 ; index < buffer_count ; index++ ) { |
---|
| 185 | |
---|
| 186 | status = rtems_partition_return_buffer( |
---|
| 187 | Partition_id, |
---|
| 188 | Buffer_addresses[ index ] |
---|
| 189 | ); |
---|
| 190 | directive_failed( status, "rtems_partition_return_buffer" ); |
---|
| 191 | |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | Timer_initialize(); |
---|
| 195 | (void) rtems_partition_delete( Partition_id ); |
---|
| 196 | end_time = Read_timer(); |
---|
| 197 | |
---|
| 198 | put_time( |
---|
| 199 | "rtems_partition_delete", |
---|
| 200 | end_time, |
---|
| 201 | 1, |
---|
| 202 | 0, |
---|
| 203 | CALLING_OVERHEAD_PARTITION_DELETE |
---|
| 204 | ); |
---|
| 205 | |
---|
| 206 | status = rtems_region_get_segment( |
---|
| 207 | Region_id, |
---|
| 208 | 400, |
---|
| 209 | RTEMS_DEFAULT_OPTIONS, |
---|
| 210 | RTEMS_NO_TIMEOUT, |
---|
| 211 | &Buffer_address_2 |
---|
| 212 | ); |
---|
| 213 | directive_failed( status, "region_get_semgent" ); |
---|
| 214 | |
---|
| 215 | Timer_initialize(); |
---|
| 216 | (void) rtems_region_get_segment( |
---|
| 217 | Region_id, |
---|
| 218 | 400, |
---|
| 219 | RTEMS_DEFAULT_OPTIONS, |
---|
| 220 | RTEMS_NO_TIMEOUT, |
---|
| 221 | &Buffer_address_3 |
---|
| 222 | ); |
---|
| 223 | end_time = Read_timer(); |
---|
| 224 | |
---|
| 225 | put_time( |
---|
[5c491aef] | 226 | "rtems_region_get_segment: available", |
---|
[ac7d5ef0] | 227 | end_time, |
---|
| 228 | 1, |
---|
| 229 | 0, |
---|
| 230 | CALLING_OVERHEAD_REGION_GET_SEGMENT |
---|
| 231 | ); |
---|
| 232 | |
---|
| 233 | Timer_initialize(); |
---|
| 234 | (void) rtems_region_get_segment( |
---|
| 235 | Region_id, |
---|
| 236 | 1998, |
---|
| 237 | RTEMS_NO_WAIT, |
---|
| 238 | RTEMS_NO_TIMEOUT, |
---|
| 239 | &Buffer_address_4 |
---|
| 240 | ); |
---|
| 241 | end_time = Read_timer(); |
---|
| 242 | |
---|
| 243 | put_time( |
---|
[5c491aef] | 244 | "rtems_region_get_segment: not available -- NO_WAIT", |
---|
[ac7d5ef0] | 245 | end_time, |
---|
| 246 | 1, |
---|
| 247 | 0, |
---|
| 248 | CALLING_OVERHEAD_REGION_GET_SEGMENT |
---|
| 249 | ); |
---|
| 250 | |
---|
| 251 | status = rtems_region_return_segment( Region_id, Buffer_address_3 ); |
---|
| 252 | directive_failed( status, "rtems_region_return_segment" ); |
---|
| 253 | |
---|
| 254 | Timer_initialize(); |
---|
| 255 | (void) rtems_region_return_segment( Region_id, Buffer_address_2 ); |
---|
| 256 | end_time = Read_timer(); |
---|
| 257 | |
---|
| 258 | put_time( |
---|
[5c491aef] | 259 | "rtems_region_return_segment: no waiting tasks", |
---|
[ac7d5ef0] | 260 | end_time, |
---|
| 261 | 1, |
---|
| 262 | 0, |
---|
| 263 | CALLING_OVERHEAD_REGION_RETURN_SEGMENT |
---|
| 264 | ); |
---|
| 265 | |
---|
| 266 | status = rtems_region_get_segment( |
---|
| 267 | Region_id, |
---|
| 268 | 400, |
---|
| 269 | RTEMS_DEFAULT_OPTIONS, |
---|
| 270 | RTEMS_NO_TIMEOUT, |
---|
| 271 | &Buffer_address_1 |
---|
| 272 | ); |
---|
| 273 | directive_failed( status, "rtems_region_get_segment" ); |
---|
| 274 | |
---|
| 275 | Timer_initialize(); |
---|
| 276 | (void) rtems_region_get_segment( |
---|
| 277 | Region_id, |
---|
| 278 | 1998, |
---|
| 279 | RTEMS_DEFAULT_OPTIONS, |
---|
| 280 | RTEMS_NO_TIMEOUT, |
---|
| 281 | &Buffer_address_2 |
---|
| 282 | ); |
---|
| 283 | |
---|
| 284 | /* execute Task_2 */ |
---|
| 285 | |
---|
| 286 | end_time = Read_timer(); |
---|
| 287 | |
---|
| 288 | put_time( |
---|
[5c491aef] | 289 | "rtems_region_return_segment: task readied -- preempts caller", |
---|
[ac7d5ef0] | 290 | end_time, |
---|
| 291 | 1, |
---|
| 292 | 0, |
---|
| 293 | CALLING_OVERHEAD_REGION_RETURN_SEGMENT |
---|
| 294 | ); |
---|
| 295 | |
---|
| 296 | status = rtems_region_return_segment( Region_id, Buffer_address_2 ); |
---|
| 297 | directive_failed( status, "rtems_region_return_segment" ); |
---|
| 298 | |
---|
| 299 | status = rtems_task_mode( |
---|
| 300 | RTEMS_NO_PREEMPT, |
---|
| 301 | RTEMS_PREEMPT_MASK, |
---|
| 302 | &previous_mode |
---|
| 303 | ); |
---|
| 304 | directive_failed( status, "rtems_task_mode" ); |
---|
| 305 | |
---|
| 306 | status = rtems_task_set_priority( RTEMS_SELF, 254, &previous_priority ); |
---|
| 307 | directive_failed( status, "rtems_task_set_priority" ); |
---|
| 308 | |
---|
| 309 | status = rtems_region_get_segment( |
---|
| 310 | Region_id, |
---|
| 311 | 400, |
---|
| 312 | RTEMS_DEFAULT_OPTIONS, |
---|
| 313 | RTEMS_NO_TIMEOUT, |
---|
| 314 | &Buffer_address_1 |
---|
| 315 | ); |
---|
| 316 | directive_failed( status, "rtems_region_return_segment" ); |
---|
| 317 | |
---|
| 318 | status = rtems_region_get_segment( |
---|
| 319 | Region_id, |
---|
| 320 | 1998, |
---|
| 321 | RTEMS_DEFAULT_OPTIONS, |
---|
| 322 | RTEMS_NO_TIMEOUT, |
---|
| 323 | &Buffer_address_2 |
---|
| 324 | ); |
---|
| 325 | directive_failed( status, "rtems_region_get_segment" ); |
---|
| 326 | |
---|
| 327 | /* execute Task_2 */ |
---|
| 328 | |
---|
| 329 | status = rtems_region_return_segment( Region_id, Buffer_address_2 ); |
---|
| 330 | directive_failed( status, "rtems_region_return_segment" ); |
---|
| 331 | |
---|
| 332 | Timer_initialize(); |
---|
| 333 | (void) rtems_region_delete( Region_id ); |
---|
| 334 | end_time = Read_timer(); |
---|
| 335 | |
---|
| 336 | put_time( |
---|
| 337 | "rtems_region_delete", |
---|
| 338 | end_time, |
---|
| 339 | 1, |
---|
| 340 | 0, |
---|
| 341 | CALLING_OVERHEAD_REGION_DELETE |
---|
| 342 | ); |
---|
| 343 | |
---|
| 344 | Timer_initialize(); |
---|
| 345 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
| 346 | (void) Empty_function(); |
---|
| 347 | overhead = Read_timer(); |
---|
| 348 | |
---|
| 349 | Timer_initialize(); |
---|
| 350 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[3652ad35] | 351 | (void) rtems_io_initialize( _STUB_major, 0, NULL ); |
---|
[ac7d5ef0] | 352 | end_time = Read_timer(); |
---|
| 353 | |
---|
| 354 | put_time( |
---|
| 355 | "rtems_io_initialize", |
---|
| 356 | end_time, |
---|
| 357 | OPERATION_COUNT, |
---|
| 358 | overhead, |
---|
| 359 | CALLING_OVERHEAD_IO_INITIALIZE |
---|
| 360 | ); |
---|
| 361 | |
---|
| 362 | Timer_initialize(); |
---|
| 363 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[3652ad35] | 364 | (void) rtems_io_open( _STUB_major, 0, NULL ); |
---|
[ac7d5ef0] | 365 | end_time = Read_timer(); |
---|
| 366 | |
---|
| 367 | put_time( |
---|
| 368 | "rtems_io_open", |
---|
| 369 | end_time, |
---|
| 370 | OPERATION_COUNT, |
---|
| 371 | overhead, |
---|
| 372 | CALLING_OVERHEAD_IO_OPEN |
---|
| 373 | ); |
---|
| 374 | |
---|
| 375 | Timer_initialize(); |
---|
| 376 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[3652ad35] | 377 | (void) rtems_io_close( _STUB_major, 0, NULL ); |
---|
[ac7d5ef0] | 378 | end_time = Read_timer(); |
---|
| 379 | |
---|
| 380 | put_time( |
---|
| 381 | "rtems_io_close", |
---|
| 382 | end_time, |
---|
| 383 | OPERATION_COUNT, |
---|
| 384 | overhead, |
---|
| 385 | CALLING_OVERHEAD_IO_CLOSE |
---|
| 386 | ); |
---|
| 387 | |
---|
| 388 | Timer_initialize(); |
---|
| 389 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[3652ad35] | 390 | (void) rtems_io_read( _STUB_major, 0, NULL ); |
---|
[ac7d5ef0] | 391 | end_time = Read_timer(); |
---|
| 392 | |
---|
| 393 | put_time( |
---|
| 394 | "rtems_io_read", |
---|
| 395 | end_time, |
---|
| 396 | OPERATION_COUNT, |
---|
| 397 | overhead, |
---|
| 398 | CALLING_OVERHEAD_IO_READ |
---|
| 399 | ); |
---|
| 400 | |
---|
| 401 | Timer_initialize(); |
---|
| 402 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[3652ad35] | 403 | (void) rtems_io_write( _STUB_major, 0, NULL ); |
---|
[ac7d5ef0] | 404 | end_time = Read_timer(); |
---|
| 405 | |
---|
| 406 | put_time( |
---|
| 407 | "rtems_io_write", |
---|
| 408 | end_time, |
---|
| 409 | OPERATION_COUNT, |
---|
| 410 | overhead, |
---|
| 411 | CALLING_OVERHEAD_IO_WRITE |
---|
| 412 | ); |
---|
| 413 | |
---|
| 414 | Timer_initialize(); |
---|
| 415 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
[3652ad35] | 416 | (void) rtems_io_control( _STUB_major, 0, NULL ); |
---|
[ac7d5ef0] | 417 | end_time = Read_timer(); |
---|
| 418 | |
---|
| 419 | put_time( |
---|
| 420 | "rtems_io_control", |
---|
| 421 | end_time, |
---|
| 422 | OPERATION_COUNT, |
---|
| 423 | overhead, |
---|
| 424 | CALLING_OVERHEAD_IO_CONTROL |
---|
| 425 | ); |
---|
| 426 | |
---|
[3a4ae6c] | 427 | puts( "*** END OF TEST 20 ***" ); |
---|
[ac7d5ef0] | 428 | exit( 0 ); |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | rtems_task Task_2( |
---|
| 432 | rtems_task_argument argument |
---|
| 433 | ) |
---|
| 434 | { |
---|
| 435 | rtems_status_code status; |
---|
| 436 | |
---|
| 437 | end_time = Read_timer(); |
---|
| 438 | |
---|
| 439 | put_time( |
---|
[5c491aef] | 440 | "rtems_region_get_segment: not available -- caller blocks", |
---|
[ac7d5ef0] | 441 | end_time, |
---|
| 442 | 1, |
---|
| 443 | 0, |
---|
| 444 | CALLING_OVERHEAD_REGION_GET_SEGMENT |
---|
| 445 | ); |
---|
| 446 | |
---|
| 447 | Timer_initialize(); |
---|
| 448 | (void) rtems_region_return_segment( Region_id, Buffer_address_1 ); |
---|
| 449 | |
---|
| 450 | /* preempt back to Task_1 */ |
---|
| 451 | |
---|
| 452 | Timer_initialize(); |
---|
| 453 | (void) rtems_region_return_segment( Region_id, Buffer_address_1 ); |
---|
| 454 | end_time = Read_timer(); |
---|
| 455 | |
---|
| 456 | put_time( |
---|
[5c491aef] | 457 | "rtems_region_return_segment: task readied -- returns to caller", |
---|
[ac7d5ef0] | 458 | end_time, |
---|
| 459 | 1, |
---|
| 460 | 0, |
---|
| 461 | CALLING_OVERHEAD_REGION_RETURN_SEGMENT |
---|
| 462 | ); |
---|
| 463 | |
---|
| 464 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 465 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 466 | } |
---|