source: rtems/testsuites/tmtests/tm15/task1.c @ 2ead50a

4.115
Last change on this file since 2ead50a was 2ead50a, checked in by bjorn larsson <bjornlarsson@…>, on 03/21/14 at 15:48:01

tmtests: convert to test.h

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