[ac7d5ef0] | 1 | /* Test_task |
---|
| 2 | * |
---|
| 3 | * This task is used for three test tasks. It obtains its task id and |
---|
| 4 | * based upon that id, performs certain actions. |
---|
| 5 | * |
---|
| 6 | * Task_1 delays 5 seconds and deletes itself. |
---|
| 7 | * Task_2 delays 10 seconds and then loops until |
---|
| 8 | * deleted by the third task. |
---|
| 9 | * Task 3 delays 15 seconds, then deletes task 2 and itself. |
---|
| 10 | * |
---|
| 11 | * Input parameters: |
---|
| 12 | * argument - task argument |
---|
| 13 | * |
---|
| 14 | * Output parameters: NONE |
---|
| 15 | * |
---|
[9992cac] | 16 | * COPYRIGHT (c) 1989-2009. |
---|
[ac7d5ef0] | 17 | * On-Line Applications Research Corporation (OAR). |
---|
| 18 | * |
---|
[98e4ebf5] | 19 | * The license and distribution terms for this file may be |
---|
| 20 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 21 | * http://www.rtems.org/license/LICENSE. |
---|
[ac7d5ef0] | 22 | */ |
---|
| 23 | |
---|
[a4bc4d6e] | 24 | #ifdef HAVE_CONFIG_H |
---|
| 25 | #include "config.h" |
---|
| 26 | #endif |
---|
| 27 | |
---|
[ac7d5ef0] | 28 | #include "system.h" |
---|
| 29 | |
---|
| 30 | rtems_task Test_task( |
---|
| 31 | rtems_task_argument argument |
---|
| 32 | ) |
---|
| 33 | { |
---|
| 34 | rtems_status_code status; |
---|
| 35 | rtems_id tid; |
---|
| 36 | rtems_time_of_day time; |
---|
| 37 | |
---|
| 38 | status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); |
---|
| 39 | directive_failed( status, "rtems_task_ident" ); |
---|
| 40 | |
---|
[573f8d4] | 41 | status = rtems_clock_get_tod( &time ); |
---|
| 42 | directive_failed( status, "rtems_clock_get_tod" ); |
---|
[ac7d5ef0] | 43 | |
---|
| 44 | put_name( Task_name[ task_number( tid ) ], FALSE ); |
---|
[573f8d4] | 45 | print_time( " - rtems_clock_get_tod - ", &time, "\n" ); |
---|
[ac7d5ef0] | 46 | |
---|
[9992cac] | 47 | status = rtems_task_wake_after( task_number( tid ) * 1 * rtems_clock_get_ticks_per_second() ); |
---|
[ac7d5ef0] | 48 | directive_failed( status, "rtems_task_wake_after" ); |
---|
| 49 | |
---|
[573f8d4] | 50 | status = rtems_clock_get_tod( &time ); |
---|
| 51 | directive_failed( status, "rtems_clock_get_tod" ); |
---|
[ac7d5ef0] | 52 | put_name( Task_name[ task_number( tid ) ], FALSE ); |
---|
[573f8d4] | 53 | print_time( " - rtems_clock_get_tod - ", &time, "\n" ); |
---|
[ac7d5ef0] | 54 | |
---|
| 55 | if ( task_number(tid) == 1 ) { /* TASK 1 */ |
---|
| 56 | put_name( Task_name[ 1 ], FALSE ); |
---|
| 57 | printf( " - deleting self\n" ); |
---|
[51b3cbca] | 58 | rtems_task_exit(); |
---|
[ac7d5ef0] | 59 | } |
---|
| 60 | else if ( task_number(tid) == 2 ) { /* TASK 2 */ |
---|
| 61 | put_name( Task_name[ 2 ], FALSE ); |
---|
| 62 | printf( " - waiting to be deleted by " ); |
---|
| 63 | put_name( Task_name[ 3 ], TRUE ); |
---|
| 64 | while ( FOREVER ); |
---|
| 65 | } |
---|
| 66 | else { /* TASK 3 */ |
---|
| 67 | put_name( Task_name[ 3 ], FALSE ); |
---|
| 68 | printf( " - getting TID of " ); |
---|
| 69 | put_name( Task_name[ 2 ], TRUE ); |
---|
| 70 | do { |
---|
| 71 | status = rtems_task_ident( Task_name[ 2 ], RTEMS_SEARCH_ALL_NODES, &tid ); |
---|
| 72 | } while ( status != RTEMS_SUCCESSFUL ); |
---|
| 73 | directive_failed( status, "rtems_task_ident" ); |
---|
| 74 | |
---|
| 75 | put_name( Task_name[ 3 ], FALSE ); |
---|
| 76 | printf( " - deleting " ); |
---|
| 77 | put_name( Task_name[ 2 ], TRUE ); |
---|
| 78 | status = rtems_task_delete( tid ); |
---|
| 79 | directive_failed( status, "rtems_task_delete of Task 2" ); |
---|
| 80 | |
---|
| 81 | puts( "*** END OF TEST 1 ***" ); |
---|
[116845e8] | 82 | rtems_test_exit(0); |
---|
[ac7d5ef0] | 83 | } |
---|
| 84 | } |
---|