source: rtems/testsuites/tmtests/tm10/task1.c @ 8b73ee5

5
Last change on this file since 8b73ee5 was fdeaa64, checked in by Sebastian Huber <sebastian.huber@…>, on 03/03/20 at 12:01:56

config: Remove <rtems/btimer.h> include

The use of CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER does not define
anything, so remove the <rtems/btimer.h> include.

Update #3875.

  • Property mode set to 100644
File size: 3.5 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#if !defined(OPERATION_COUNT)
11#define OPERATION_COUNT 100
12#endif
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/btimer.h>
19
20#define CONFIGURE_INIT
21#include "system.h"
22
23const char rtems_test_name[] = "TIME TEST 10";
24
25rtems_id Queue_id;
26long Buffer[4];
27
28rtems_task High_task(
29  rtems_task_argument argument
30);
31
32rtems_task Middle_tasks(
33  rtems_task_argument argument
34);
35
36rtems_task Low_task(
37  rtems_task_argument argument
38);
39
40void test_init(void);
41
42int operation_count = OPERATION_COUNT;
43
44rtems_task Init(
45  rtems_task_argument argument
46)
47{
48  Print_Warning();
49
50  TEST_BEGIN();
51
52  test_init();
53
54  rtems_task_exit();
55}
56
57void test_init()
58{
59  int                 index;
60  size_t              size;
61  rtems_task_entry    task_entry;
62  rtems_status_code   status;
63  rtems_task_priority priority;
64  rtems_id            task_id;
65
66  priority = 2;
67
68  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
69    operation_count =  RTEMS_MAXIMUM_PRIORITY - 2;
70
71  for( index = 0; index < operation_count ; index++ ) {
72    status = rtems_task_create(
73      rtems_build_name( 'T', 'I', 'M', 'E' ),
74      priority,
75      RTEMS_MINIMUM_STACK_SIZE,
76      RTEMS_DEFAULT_MODES,
77      RTEMS_DEFAULT_ATTRIBUTES,
78      &task_id
79    );
80    directive_failed( status, "rtems_task_create LOOP" );
81
82    priority++;
83
84    if ( index==0 )                    task_entry = High_task;
85    else if ( index==operation_count-1 ) task_entry = Low_task;
86    else                               task_entry = Middle_tasks;
87
88    status = rtems_task_start( task_id, task_entry, 0 );
89    directive_failed( status, "rtems_task_start LOOP" );
90  }
91
92  status = rtems_message_queue_create(
93    1,
94    (uint32_t)operation_count,
95    16,
96    RTEMS_DEFAULT_ATTRIBUTES,
97    &Queue_id
98  );
99  directive_failed( status, "rtems_message_queue_create" );
100
101  benchmark_timer_initialize();
102    for ( index=1 ; index < operation_count ; index++ )
103      (void) benchmark_timer_empty_function();
104  overhead = benchmark_timer_read();
105
106  benchmark_timer_initialize();
107    for ( index=1 ; index < operation_count ; index++ )
108      (void) rtems_message_queue_receive(
109               Queue_id,
110               (long (*)[4]) Buffer,
111               &size,
112               RTEMS_NO_WAIT,
113               RTEMS_NO_TIMEOUT
114             );
115  end_time = benchmark_timer_read();
116
117  put_time(
118    "rtems_message_queue_receive: not available NO_WAIT",
119    end_time,
120    operation_count,
121    overhead,
122    0
123  );
124
125}
126
127rtems_task High_task(
128  rtems_task_argument argument
129)
130{
131  size_t  size;
132
133  benchmark_timer_initialize();
134     (void) rtems_message_queue_receive(
135              Queue_id,
136              (long (*)[4]) Buffer,
137              &size,
138              RTEMS_DEFAULT_OPTIONS,
139              RTEMS_NO_TIMEOUT
140            );
141}
142
143rtems_task Middle_tasks(
144  rtems_task_argument argument
145)
146{
147  size_t  size;
148
149  (void) rtems_message_queue_receive(
150           Queue_id,
151           (long (*)[4]) Buffer,
152           &size,
153           RTEMS_DEFAULT_OPTIONS,
154           RTEMS_NO_TIMEOUT
155         );
156}
157
158
159rtems_task Low_task(
160  rtems_task_argument argument
161)
162{
163  end_time = benchmark_timer_read();
164
165  put_time(
166    "rtems_message_queue_receive: not available caller blocks",
167    end_time,
168    operation_count - 1,
169    0,
170    0
171  );
172
173  TEST_END();
174  rtems_test_exit( 0 );
175}
Note: See TracBrowser for help on using the repository browser.