source: rtems/testsuites/tmtests/tm10/task1.c @ 98c6d50

5
Last change on this file since 98c6d50 was 98c6d50, checked in by Chris Johns <chrisj@…>, on 10/19/17 at 05:39:16

testsuite: Use printk for all test output where possible.

  • Remove the printf support leaving the direct printk support configured with TESTS_USE_PRINTK and all other output goes via a buffered vsniprintf call to printk.
  • Control the test's single init for functions and global data with TEST_INIT and not CONFIGURE_INIT. They are now separate.

Updates #3170.

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