[f4a8ee1] | 1 | /* Init |
---|
| 2 | * |
---|
| 3 | * This routine is the initialization task for this test program. |
---|
| 4 | * It is called from init_exec and has the responsibility for creating |
---|
| 5 | * and starting the tasks that make up the test. If the time of day |
---|
| 6 | * clock is required for the test, it should also be set to a known |
---|
| 7 | * value by this function. |
---|
| 8 | * |
---|
| 9 | * Input parameters: NONE |
---|
| 10 | * |
---|
| 11 | * Output parameters: NONE |
---|
| 12 | * |
---|
| 13 | * COPYRIGHT (c) 1989-1997. |
---|
| 14 | * On-Line Applications Research Corporation (OAR). |
---|
| 15 | * |
---|
| 16 | * The license and distribution terms for this file may in |
---|
| 17 | * the file LICENSE in this distribution or at |
---|
[3e26377b] | 18 | * http://www.rtems.com/license/LICENSE. |
---|
[f4a8ee1] | 19 | * |
---|
| 20 | * $Id$ |
---|
| 21 | */ |
---|
| 22 | |
---|
[df49c60] | 23 | #define CONFIGURE_INIT |
---|
[f4a8ee1] | 24 | |
---|
| 25 | #include "system.h" |
---|
| 26 | #include <stdio.h> |
---|
[d25d17b] | 27 | #include <stdlib.h> |
---|
[f4a8ee1] | 28 | |
---|
| 29 | rtems_id task_id[MAX_TASKS]; |
---|
| 30 | |
---|
| 31 | void test1(); |
---|
| 32 | void test2(); |
---|
| 33 | |
---|
| 34 | rtems_task Init( |
---|
| 35 | rtems_task_argument ignored |
---|
| 36 | ) |
---|
| 37 | { |
---|
| 38 | rtems_task_priority old_priority; |
---|
| 39 | rtems_mode old_mode; |
---|
[4c84d7b] | 40 | uint32_t task; |
---|
[f4a8ee1] | 41 | |
---|
| 42 | /* lower the task priority to allow created tasks to execute */ |
---|
[8f71a36] | 43 | |
---|
[f4a8ee1] | 44 | rtems_task_set_priority(RTEMS_SELF, 20, &old_priority); |
---|
| 45 | rtems_task_mode(RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode); |
---|
[8f71a36] | 46 | |
---|
[f4a8ee1] | 47 | printf( "\n*** UNLIMITED TASK TEST ***\n" ); |
---|
| 48 | |
---|
| 49 | /* |
---|
| 50 | * Invalid state if the task id is 0 |
---|
| 51 | */ |
---|
[8f71a36] | 52 | |
---|
[f4a8ee1] | 53 | for (task = 0; task < MAX_TASKS; task++) |
---|
| 54 | task_id[task] = 0; |
---|
| 55 | |
---|
| 56 | test1(); |
---|
| 57 | test2(); |
---|
| 58 | test3(); |
---|
[8f71a36] | 59 | |
---|
[f4a8ee1] | 60 | printf( "\n*** END OF UNLIMITED TASK TEST ***\n" ); |
---|
| 61 | exit( 0 ); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | rtems_task test_task( |
---|
| 65 | rtems_task_argument my_number |
---|
| 66 | ) |
---|
| 67 | { |
---|
| 68 | rtems_event_set out; |
---|
[8f71a36] | 69 | |
---|
[f4a8ee1] | 70 | printf( "task %i has started.\n", my_number); |
---|
| 71 | |
---|
| 72 | rtems_event_receive(1, RTEMS_WAIT | RTEMS_EVENT_ANY, 0, &out); |
---|
[8f71a36] | 73 | |
---|
[f4a8ee1] | 74 | printf( "task %i ending.\n", my_number); |
---|
| 75 | |
---|
| 76 | rtems_task_delete(RTEMS_SELF); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | void destory_all_tasks( |
---|
| 80 | const char *who |
---|
| 81 | ) |
---|
| 82 | { |
---|
[4c84d7b] | 83 | uint32_t task; |
---|
[8f71a36] | 84 | |
---|
[f4a8ee1] | 85 | /* |
---|
| 86 | * If the id is not zero, signal the task to delete. |
---|
| 87 | */ |
---|
[8f71a36] | 88 | |
---|
[f4a8ee1] | 89 | for (task = 0; task < MAX_TASKS; task++) |
---|
| 90 | if (task_id[task]) |
---|
| 91 | { |
---|
| 92 | printf(" %s : signal task %08x to delete, ", who, task_id[task]); |
---|
[f59df6b2] | 93 | fflush(stdout); |
---|
[f4a8ee1] | 94 | rtems_event_send(task_id[task], 1); |
---|
| 95 | task_id[task] = 0; |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | boolean status_code_bad( |
---|
| 100 | rtems_status_code status_code |
---|
| 101 | ) |
---|
| 102 | { |
---|
| 103 | if (status_code != RTEMS_SUCCESSFUL) |
---|
| 104 | { |
---|
| 105 | printf("failure, "); |
---|
[8f71a36] | 106 | |
---|
[f4a8ee1] | 107 | if (status_code == RTEMS_TOO_MANY) |
---|
| 108 | { |
---|
[8f71a36] | 109 | printf("too many.\n"); |
---|
[f4a8ee1] | 110 | return TRUE; |
---|
| 111 | } |
---|
| 112 | if (status_code == RTEMS_UNSATISFIED) |
---|
| 113 | { |
---|
[8f71a36] | 114 | printf("unsatisfied.\n"); |
---|
[f4a8ee1] | 115 | return TRUE; |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | printf("error code = %i\n", status_code); |
---|
| 119 | exit( 1 ); |
---|
| 120 | } |
---|
| 121 | return FALSE; |
---|
| 122 | } |
---|