source: rtems/c/src/tests/tmtests/tm15/task1.c @ 3652ad35

4.104.114.84.95
Last change on this file since 3652ad35 was 3652ad35, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 19, 1995 at 2:53:29 PM

Minor bug fixes to get all targets compilable and running. The
single biggest changes were the expansion of the workspace size
macro to include other types of objects and the increase in the
minimum stack size for most CPUs.

  • Property mode set to 100644
File size: 4.6 KB
Line 
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#define TEST_INIT
15#include "system.h"
16
17rtems_unsigned32 time_set, eventout;
18
19rtems_task High_tasks(
20  rtems_task_argument argument
21);
22
23rtems_task Low_task(
24  rtems_task_argument argument
25);
26
27void test_init();
28
29rtems_task Init(
30  rtems_task_argument argument
31)
32{
33  rtems_status_code status;
34
35  Print_Warning();
36
37  puts( "\n\n*** TIME TEST 15 ***" );
38
39  test_init();
40
41  status = rtems_task_delete( RTEMS_SELF );
42  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
43}
44
45void test_init()
46{
47  rtems_id          id;
48  rtems_unsigned32  index;
49  rtems_event_set   event_out;
50  rtems_status_code status;
51
52  time_set = FALSE;
53
54  status = rtems_task_create(
55    rtems_build_name( 'L', 'O', 'W', ' ' ),
56    10,
57    RTEMS_MINIMUM_STACK_SIZE,
58    RTEMS_NO_PREEMPT,
59    RTEMS_DEFAULT_ATTRIBUTES,
60    &id
61  );
62  directive_failed( status, "rtems_task_create LOW" );
63
64  status = rtems_task_start( id, Low_task, 0 );
65  directive_failed( status, "rtems_task_start LOW" );
66
67  for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) {
68    status = rtems_task_create(
69      rtems_build_name( 'H', 'I', 'G', 'H' ),
70      5,
71      RTEMS_MINIMUM_STACK_SIZE,
72      RTEMS_DEFAULT_MODES,
73      RTEMS_DEFAULT_ATTRIBUTES,
74      &Task_id[ index ]
75    );
76    directive_failed( status, "rtems_task_create LOOP" );
77
78    status = rtems_task_start( Task_id[ index ], High_tasks, 0 );
79    directive_failed( status, "rtems_task_start LOOP" );
80  }
81
82  Timer_initialize();
83    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
84      (void) Empty_function();
85  overhead = Read_timer();
86
87  Timer_initialize();
88    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
89    {
90        (void) rtems_event_receive(
91                 RTEMS_PENDING_EVENTS,
92                 RTEMS_DEFAULT_OPTIONS,
93                 RTEMS_NO_TIMEOUT,
94                 &event_out
95               );
96    }
97
98  end_time = Read_timer();
99
100  put_time(
101    "rtems_event_receive (current)",
102    end_time,
103    OPERATION_COUNT,
104    overhead,
105    CALLING_OVERHEAD_EVENT_RECEIVE
106  );
107
108
109  Timer_initialize();
110    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
111    {
112      (void) rtems_event_receive(
113               RTEMS_ALL_EVENTS,
114               RTEMS_NO_WAIT,
115               RTEMS_NO_TIMEOUT,
116               &event_out
117             );
118    }
119  end_time = Read_timer();
120
121  put_time(
122    "rtems_event_receive (RTEMS_NO_WAIT)",
123    end_time,
124    OPERATION_COUNT,
125    overhead,
126    CALLING_OVERHEAD_EVENT_RECEIVE
127  );
128}
129
130rtems_task Low_task(
131  rtems_task_argument argument
132)
133{
134  rtems_unsigned32  index;
135  rtems_event_set   event_out;
136
137  end_time = Read_timer();
138
139  put_time(
140    "rtems_event_receive (blocking)",
141    end_time,
142    OPERATION_COUNT,
143    0,
144    CALLING_OVERHEAD_EVENT_RECEIVE
145  );
146
147  Timer_initialize();
148    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
149      (void) Empty_function();
150  overhead = Read_timer();
151
152  Timer_initialize();
153    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
154      (void) rtems_event_send( RTEMS_SELF, RTEMS_EVENT_16 );
155  end_time = Read_timer();
156
157  put_time(
158    "rtems_event_send (non-blocking)",
159    end_time,
160    OPERATION_COUNT,
161    overhead,
162    CALLING_OVERHEAD_EVENT_SEND
163  );
164
165  Timer_initialize();
166    (void) rtems_event_receive(
167             RTEMS_EVENT_16,
168             RTEMS_DEFAULT_OPTIONS,
169             RTEMS_NO_TIMEOUT,
170             &event_out
171           );
172  end_time = Read_timer();
173
174  put_time(
175    "rtems_event_receive (available)",
176    end_time,
177    1,
178    0,
179    CALLING_OVERHEAD_EVENT_RECEIVE
180  );
181
182  Timer_initialize();
183    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
184      (void) rtems_event_send( Task_id[ index ], RTEMS_EVENT_16 );
185  end_time = Read_timer();
186
187  put_time(
188    "rtems_event_send (readying)",
189    end_time,
190    OPERATION_COUNT,
191    overhead,
192    CALLING_OVERHEAD_EVENT_SEND
193  );
194
195  puts( "*** END OF TEST 15 ***" );
196  exit( 0 );
197}
198
199rtems_task High_tasks(
200  rtems_task_argument argument
201)
202{
203  rtems_status_code status;
204
205  if ( time_set )
206    status = rtems_event_receive(
207      RTEMS_EVENT_16,
208      RTEMS_DEFAULT_OPTIONS,
209      RTEMS_NO_TIMEOUT,
210      &eventout
211    );
212  else {
213    time_set = 1;
214    Timer_initialize();            /* start blocking rtems_event_receive time */
215    status = rtems_event_receive(
216      RTEMS_EVENT_16,
217      RTEMS_DEFAULT_OPTIONS,
218      RTEMS_NO_TIMEOUT,
219      &eventout
220    );
221  }
222}
Note: See TracBrowser for help on using the repository browser.