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
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
[256d779]17bool     time_set;
18uint32_t eventout;
[ac7d5ef0]19
20rtems_task High_tasks(
21  rtems_task_argument argument
22);
23
24rtems_task Low_task(
25  rtems_task_argument argument
26);
27
[1055ce20]28void test_init(void);
[ac7d5ef0]29
30rtems_task Init(
31  rtems_task_argument argument
32)
33{
34  rtems_status_code status;
35
[3a4ae6c]36  Print_Warning();
37
[ac7d5ef0]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
[1055ce20]46void test_init(void)
[ac7d5ef0]47{
48  rtems_id          id;
[0720ff4]49  uint32_t    index;
[ac7d5ef0]50  rtems_event_set   event_out;
51  rtems_status_code status;
52
[256d779]53  time_set = false;
[ac7d5ef0]54
55  status = rtems_task_create(
56    rtems_build_name( 'L', 'O', 'W', ' ' ),
57    10,
[3652ad35]58    RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]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,
[3652ad35]72      RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]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
[dbf4f17]83  benchmark_timer_initialize();
[ac7d5ef0]84    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
[dbf4f17]85      (void) benchmark_timer_empty_function();
86  overhead = benchmark_timer_read();
[ac7d5ef0]87
[dbf4f17]88  benchmark_timer_initialize();
[ac7d5ef0]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
[dbf4f17]99  end_time = benchmark_timer_read();
[ac7d5ef0]100
101  put_time(
[5c491aef]102    "rtems_event_receive: obtain current events",
[ac7d5ef0]103    end_time,
104    OPERATION_COUNT,
105    overhead,
106    CALLING_OVERHEAD_EVENT_RECEIVE
107  );
108
109
[dbf4f17]110  benchmark_timer_initialize();
[ac7d5ef0]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    }
[dbf4f17]120  end_time = benchmark_timer_read();
[ac7d5ef0]121
122  put_time(
[9410d011]123    "rtems_event_receive: not available NO_WAIT",
[ac7d5ef0]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{
[0720ff4]135  uint32_t    index;
[ac7d5ef0]136  rtems_event_set   event_out;
137
[dbf4f17]138  end_time = benchmark_timer_read();
[ac7d5ef0]139
140  put_time(
[9410d011]141    "rtems_event_receive: not available caller blocks",
[ac7d5ef0]142    end_time,
143    OPERATION_COUNT,
144    0,
145    CALLING_OVERHEAD_EVENT_RECEIVE
146  );
147
[dbf4f17]148  benchmark_timer_initialize();
[ac7d5ef0]149    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
[dbf4f17]150      (void) benchmark_timer_empty_function();
151  overhead = benchmark_timer_read();
[ac7d5ef0]152
[dbf4f17]153  benchmark_timer_initialize();
[ac7d5ef0]154    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
155      (void) rtems_event_send( RTEMS_SELF, RTEMS_EVENT_16 );
[dbf4f17]156  end_time = benchmark_timer_read();
[ac7d5ef0]157
158  put_time(
[5c491aef]159    "rtems_event_send: no task readied",
[ac7d5ef0]160    end_time,
161    OPERATION_COUNT,
162    overhead,
163    CALLING_OVERHEAD_EVENT_SEND
164  );
165
[dbf4f17]166  benchmark_timer_initialize();
[ac7d5ef0]167    (void) rtems_event_receive(
168             RTEMS_EVENT_16,
169             RTEMS_DEFAULT_OPTIONS,
170             RTEMS_NO_TIMEOUT,
171             &event_out
172           );
[dbf4f17]173  end_time = benchmark_timer_read();
[ac7d5ef0]174
175  put_time(
[5c491aef]176    "rtems_event_receive: available",
[ac7d5ef0]177    end_time,
178    1,
179    0,
180    CALLING_OVERHEAD_EVENT_RECEIVE
181  );
182
[dbf4f17]183  benchmark_timer_initialize();
[ac7d5ef0]184    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
185      (void) rtems_event_send( Task_id[ index ], RTEMS_EVENT_16 );
[dbf4f17]186  end_time = benchmark_timer_read();
[ac7d5ef0]187
188  put_time(
[9410d011]189    "rtems_event_send: task readied returns to caller",
[ac7d5ef0]190    end_time,
191    OPERATION_COUNT,
192    overhead,
193    CALLING_OVERHEAD_EVENT_SEND
194  );
195
[3a4ae6c]196  puts( "*** END OF TEST 15 ***" );
[b454bc9]197  rtems_test_exit( 0 );
[ac7d5ef0]198}
199
200rtems_task High_tasks(
201  rtems_task_argument argument
202)
203{
204  if ( time_set )
[3f42f12c]205    (void) rtems_event_receive(
[ac7d5ef0]206      RTEMS_EVENT_16,
207      RTEMS_DEFAULT_OPTIONS,
208      RTEMS_NO_TIMEOUT,
209      &eventout
210    );
211  else {
[256d779]212    time_set = true;
[3f42f12c]213    /* start blocking rtems_event_receive time */
214    benchmark_timer_initialize();
215    (void) rtems_event_receive(
[ac7d5ef0]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.