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