source: rtems/testsuites/tmtests/tm15/task1.c @ 6c0301d

4.115
Last change on this file since 6c0301d was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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