source: rtems/testsuites/tmtests/tm12/task1.c @ 3c78e93

Last change on this file since 3c78e93 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.3 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 12";
24
25rtems_id Queue_id;
26
27long Buffer[4];
28
29rtems_task test_init(
30  rtems_task_argument argument
31);
32
33rtems_task High_task(
34  rtems_task_argument argument
35);
36
37rtems_task Low_tasks(
38  rtems_task_argument argument
39);
40
41#define MESSAGE_SIZE (sizeof(long) * 4)
42
43int operation_count = OPERATION_COUNT;
44
45rtems_task Init(
46  rtems_task_argument argument
47)
48{
49  rtems_id          task_id;
50  rtems_status_code status;
51
52  Print_Warning();
53
54  TEST_BEGIN();
55
56  status = rtems_task_create(
57    1,
58    RTEMS_MAXIMUM_PRIORITY - 1u,
59    RTEMS_MINIMUM_STACK_SIZE,
60    RTEMS_DEFAULT_MODES,
61    RTEMS_DEFAULT_ATTRIBUTES,
62    &task_id
63  );
64  directive_failed( status, "rtems_task_create" );
65
66  status = rtems_task_start( task_id, test_init, 0 );
67  directive_failed( status, "rtems_task_start" );
68
69  rtems_task_exit();
70}
71
72rtems_task test_init(
73  rtems_task_argument argument
74)
75{
76  int                  index;
77  rtems_task_entry     task_entry;
78  rtems_task_priority  priority;
79  rtems_id             task_id;
80  rtems_status_code    status;
81
82
83  status = rtems_message_queue_create(
84    rtems_build_name( 'M', 'Q', '1', ' ' ),
85    (uint32_t) operation_count,
86    MESSAGE_SIZE,
87    RTEMS_DEFAULT_ATTRIBUTES,
88    &Queue_id
89  );
90  directive_failed( status, "rtems_message_queue_create" );
91
92  priority = RTEMS_MAXIMUM_PRIORITY - 1u;
93
94  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 )
95    operation_count =  RTEMS_MAXIMUM_PRIORITY - 2;
96
97  for( index = 0; index < operation_count ; index++ ) {
98    status = rtems_task_create(
99      rtems_build_name( 'T', 'I', 'M', 'E' ),
100      priority,
101      RTEMS_MINIMUM_STACK_SIZE,
102      RTEMS_DEFAULT_MODES,
103      RTEMS_DEFAULT_ATTRIBUTES,
104      &task_id
105    );
106    directive_failed( status, "rtems_task_create LOOP" );
107
108    priority--;
109
110    if ( index == operation_count-1 ) task_entry = High_task;
111    else                              task_entry = Low_tasks;
112
113    status = rtems_task_start( task_id, task_entry, 0 );
114    directive_failed( status, "rtems_task_start LOOP" );
115  }
116}
117
118rtems_task High_task(
119  rtems_task_argument argument
120)
121{
122  int  index;
123
124  benchmark_timer_initialize();
125    for ( index=1 ; index < operation_count ; index++ )
126      (void) benchmark_timer_empty_function();
127  overhead = benchmark_timer_read();
128
129  benchmark_timer_initialize();
130    for ( index=1 ; index < operation_count ; index++ )
131      (void) rtems_message_queue_send( Queue_id, Buffer, MESSAGE_SIZE );
132  end_time = benchmark_timer_read();
133
134  put_time(
135    "rtems_message_queue_send: task readied returns to caller",
136    end_time,
137    operation_count - 1,
138    overhead,
139    0
140  );
141
142  TEST_END();
143  rtems_test_exit( 0 );
144}
145
146rtems_task Low_tasks(
147  rtems_task_argument argument
148)
149{
150  size_t  size;
151
152  (void) rtems_message_queue_receive(
153           Queue_id,
154           (long (*)[4]) Buffer,
155           &size,
156           RTEMS_DEFAULT_OPTIONS,
157           RTEMS_NO_TIMEOUT
158         );
159}
Note: See TracBrowser for help on using the repository browser.