1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2012. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #define CONFIGURE_INIT |
---|
15 | |
---|
16 | #include "system.h" |
---|
17 | #include "tmacros.h" |
---|
18 | #include <stdio.h> |
---|
19 | #include <stdlib.h> |
---|
20 | |
---|
21 | const char rtems_test_name[] = "UNLIMITED TASK"; |
---|
22 | |
---|
23 | rtems_id task_id[MAX_TASKS]; |
---|
24 | |
---|
25 | rtems_task Init( |
---|
26 | rtems_task_argument ignored |
---|
27 | ) |
---|
28 | { |
---|
29 | rtems_task_priority old_priority; |
---|
30 | rtems_mode old_mode; |
---|
31 | uint32_t task; |
---|
32 | |
---|
33 | TEST_BEGIN(); |
---|
34 | |
---|
35 | /* lower the task priority to allow created tasks to execute */ |
---|
36 | |
---|
37 | rtems_task_set_priority( |
---|
38 | RTEMS_SELF, RTEMS_MAXIMUM_PRIORITY - 1, &old_priority); |
---|
39 | rtems_task_mode(RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode); |
---|
40 | |
---|
41 | /* |
---|
42 | * Invalid state if the task id is 0 |
---|
43 | */ |
---|
44 | |
---|
45 | for (task = 0; task < MAX_TASKS; task++) |
---|
46 | task_id[task] = 0; |
---|
47 | |
---|
48 | test1(); |
---|
49 | test2(); |
---|
50 | test3(); |
---|
51 | |
---|
52 | TEST_END(); |
---|
53 | exit( 0 ); |
---|
54 | } |
---|
55 | |
---|
56 | rtems_task test_task( |
---|
57 | rtems_task_argument my_number |
---|
58 | ) |
---|
59 | { |
---|
60 | rtems_event_set out; |
---|
61 | |
---|
62 | printf( "task %" PRIdrtems_task_argument " has started.\n", my_number); |
---|
63 | |
---|
64 | rtems_event_receive(1, RTEMS_WAIT | RTEMS_EVENT_ANY, 0, &out); |
---|
65 | |
---|
66 | printf( "task %" PRIdrtems_task_argument " ending.\n", my_number); |
---|
67 | |
---|
68 | rtems_task_delete(RTEMS_SELF); |
---|
69 | } |
---|
70 | |
---|
71 | void destory_all_tasks( |
---|
72 | const char *who |
---|
73 | ) |
---|
74 | { |
---|
75 | uint32_t task; |
---|
76 | |
---|
77 | /* |
---|
78 | * If the id is not zero, signal the task to delete. |
---|
79 | */ |
---|
80 | |
---|
81 | for (task = 0; task < MAX_TASKS; task++) |
---|
82 | if (task_id[task]) |
---|
83 | { |
---|
84 | printf(" %s : signal task %08" PRIxrtems_id " to delete, ", who, task_id[task]); |
---|
85 | fflush(stdout); |
---|
86 | rtems_event_send(task_id[task], 1); |
---|
87 | task_id[task] = 0; |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | bool status_code_bad( |
---|
92 | rtems_status_code status_code |
---|
93 | ) |
---|
94 | { |
---|
95 | if (status_code != RTEMS_SUCCESSFUL) |
---|
96 | { |
---|
97 | printf("failure, "); |
---|
98 | |
---|
99 | if (status_code == RTEMS_TOO_MANY) |
---|
100 | { |
---|
101 | printf("too many.\n"); |
---|
102 | return TRUE; |
---|
103 | } |
---|
104 | if (status_code == RTEMS_UNSATISFIED) |
---|
105 | { |
---|
106 | printf("unsatisfied.\n"); |
---|
107 | return TRUE; |
---|
108 | } |
---|
109 | |
---|
110 | printf("error code = %i\n", status_code); |
---|
111 | exit( 1 ); |
---|
112 | } |
---|
113 | return FALSE; |
---|
114 | } |
---|