source: rtems/testsuites/tmtests/tm14/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.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 14";
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  status = rtems_message_queue_create(
83    rtems_build_name( 'M', 'Q', '1', ' ' ),
84    OPERATION_COUNT,
85    MESSAGE_SIZE,
86    RTEMS_DEFAULT_ATTRIBUTES,
87    &Queue_id
88  );
89  directive_failed( status, "rtems_message_queue_create" );
90
91  priority = RTEMS_MAXIMUM_PRIORITY - 2u;
92  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
93    operation_count =  (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
94
95  for( index = 0; index < operation_count ; index++ ) {
96    status = rtems_task_create(
97      rtems_build_name( 'T', 'I', 'M', 'E' ),
98      priority,
99      RTEMS_MINIMUM_STACK_SIZE,
100      RTEMS_DEFAULT_MODES,
101      RTEMS_DEFAULT_ATTRIBUTES,
102      &task_id
103    );
104    directive_failed( status, "rtems_task_create LOOP" );
105
106    priority--;
107
108    if ( index==operation_count-1 ) task_entry = High_task;
109    else                            task_entry = Low_tasks;
110
111    status = rtems_task_start( task_id, task_entry, 0 );
112    directive_failed( status, "rtems_task_start LOOP" );
113  }
114}
115
116rtems_task High_task(
117  rtems_task_argument argument
118)
119{
120  int  index;
121
122  benchmark_timer_initialize();
123    for ( index=1 ; index < operation_count ; index++ )
124      (void) benchmark_timer_empty_function();
125  overhead = benchmark_timer_read();
126
127  benchmark_timer_initialize();
128    for ( index=1 ; index <= operation_count ; index++ )
129      (void) rtems_message_queue_urgent( Queue_id, Buffer, MESSAGE_SIZE );
130  end_time = benchmark_timer_read();
131
132  put_time(
133    "rtems_message_queue_urgent: task readied returns to caller",
134    end_time,
135    operation_count,
136    overhead,
137    0
138  );
139
140  TEST_END();
141  rtems_test_exit( 0 );
142}
143
144rtems_task Low_tasks(
145  rtems_task_argument argument
146)
147{
148  size_t  size;
149
150  (void) rtems_message_queue_receive(
151           Queue_id,
152           (long (*)[4]) Buffer,
153           &size,
154           RTEMS_DEFAULT_OPTIONS,
155           RTEMS_NO_TIMEOUT
156         );
157}
Note: See TracBrowser for help on using the repository browser.