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 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include "system.h" |
---|
15 | #undef EXTERN |
---|
16 | #define EXTERN |
---|
17 | #include "conftbl.h" |
---|
18 | #include "gvar.h" |
---|
19 | |
---|
20 | rtems_unsigned32 Task_count; |
---|
21 | |
---|
22 | rtems_task test_init( |
---|
23 | rtems_task_argument argument |
---|
24 | ); |
---|
25 | |
---|
26 | rtems_task Middle_tasks( |
---|
27 | rtems_task_argument argument |
---|
28 | ); |
---|
29 | |
---|
30 | rtems_task High_task( |
---|
31 | rtems_task_argument argument |
---|
32 | ); |
---|
33 | |
---|
34 | rtems_task Init( |
---|
35 | rtems_task_argument argument |
---|
36 | ) |
---|
37 | { |
---|
38 | rtems_id id; |
---|
39 | rtems_status_code status; |
---|
40 | |
---|
41 | puts( "\n\n*** TIME TEST 16 ***" ); |
---|
42 | |
---|
43 | status = rtems_task_create( |
---|
44 | rtems_build_name( 'T', 'E', 'S', 'T' ), |
---|
45 | 251, |
---|
46 | 2048, |
---|
47 | RTEMS_DEFAULT_MODES, |
---|
48 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
49 | &id |
---|
50 | ); |
---|
51 | directive_failed( status, "rtems_task_create of test_init" ); |
---|
52 | |
---|
53 | status = rtems_task_start( id, test_init, 0 ); |
---|
54 | directive_failed( status, "rtems_task_start of test_init" ); |
---|
55 | |
---|
56 | status = rtems_task_delete( RTEMS_SELF ); |
---|
57 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
58 | } |
---|
59 | |
---|
60 | rtems_task test_init( |
---|
61 | rtems_task_argument argument |
---|
62 | ) |
---|
63 | { |
---|
64 | rtems_task_priority priority; |
---|
65 | rtems_status_code status; |
---|
66 | rtems_unsigned32 index; |
---|
67 | rtems_task_entry task_entry; |
---|
68 | |
---|
69 | /* As each task is started, it preempts this task and |
---|
70 | * performs a blocking rtems_event_receive. Upon completion of |
---|
71 | * this loop all created tasks are blocked. |
---|
72 | */ |
---|
73 | |
---|
74 | priority = 250; |
---|
75 | |
---|
76 | for( index = 0 ; index <= OPERATION_COUNT ; index++ ) { |
---|
77 | status = rtems_task_create( |
---|
78 | rtems_build_name( 'M', 'I', 'D', ' ' ), |
---|
79 | priority, |
---|
80 | 1024, |
---|
81 | RTEMS_DEFAULT_MODES, |
---|
82 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
83 | &Task_id[ index ] |
---|
84 | ); |
---|
85 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
86 | |
---|
87 | if ( index == OPERATION_COUNT ) task_entry = High_task; |
---|
88 | else task_entry = Middle_tasks; |
---|
89 | |
---|
90 | status = rtems_task_start( Task_id[ index ], task_entry, 0 ); |
---|
91 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
92 | |
---|
93 | priority--; |
---|
94 | } |
---|
95 | |
---|
96 | Task_count = 0; |
---|
97 | |
---|
98 | Timer_initialize(); |
---|
99 | (void) rtems_event_send( Task_id[ Task_count ], RTEMS_EVENT_16 ); |
---|
100 | /* preempts task */ |
---|
101 | } |
---|
102 | |
---|
103 | rtems_task Middle_tasks( |
---|
104 | rtems_task_argument argument |
---|
105 | ) |
---|
106 | { |
---|
107 | rtems_event_set event_out; |
---|
108 | |
---|
109 | (void) rtems_event_receive( /* task blocks */ |
---|
110 | RTEMS_EVENT_16, |
---|
111 | RTEMS_DEFAULT_OPTIONS, |
---|
112 | RTEMS_NO_TIMEOUT, |
---|
113 | &event_out |
---|
114 | ); |
---|
115 | |
---|
116 | Task_count++; |
---|
117 | |
---|
118 | (void) rtems_event_send( /* preempts task */ |
---|
119 | Task_id[ Task_count ], |
---|
120 | RTEMS_EVENT_16 |
---|
121 | ); |
---|
122 | } |
---|
123 | |
---|
124 | rtems_task High_task( |
---|
125 | rtems_task_argument argument |
---|
126 | ) |
---|
127 | { |
---|
128 | rtems_event_set event_out; |
---|
129 | |
---|
130 | (void) rtems_event_receive( /* task blocks */ |
---|
131 | RTEMS_EVENT_16, |
---|
132 | RTEMS_DEFAULT_OPTIONS, |
---|
133 | RTEMS_NO_TIMEOUT, |
---|
134 | &event_out |
---|
135 | ); |
---|
136 | |
---|
137 | end_time = Read_timer(); |
---|
138 | |
---|
139 | put_time( |
---|
140 | "rtems_event_send (preemptive)", |
---|
141 | end_time, |
---|
142 | OPERATION_COUNT, |
---|
143 | 0, |
---|
144 | CALLING_OVERHEAD_EVENT_SEND |
---|
145 | ); |
---|
146 | |
---|
147 | exit( 0 ); |
---|
148 | } |
---|