source: rtems/testsuites/tmtests/tm28/task1.c @ b331f40

Last change on this file since b331f40 was b331f40, checked in by Joel Sherrill <joel@…>, on 04/01/22 at 19:05:19

testsuites/tmtests/*: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 *  COPYRIGHT (c) 1989-2013.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#if !defined(OPERATION_COUNT)
30#define OPERATION_COUNT 100
31#endif
32
33#ifdef HAVE_CONFIG_H
34#include "config.h"
35#endif
36
37#include <rtems/btimer.h>
38
39#define CONFIGURE_INIT
40#include "system.h"
41
42const char rtems_test_name[] = "TIME TEST 28";
43
44rtems_id Port_id;
45
46uint8_t   Internal_area[ 256 ] CPU_STRUCTURE_ALIGNMENT;
47uint8_t   External_area[ 256 ] CPU_STRUCTURE_ALIGNMENT;
48
49rtems_task Test_task(
50  rtems_task_argument argument
51);
52
53rtems_task Init(
54  rtems_task_argument argument
55)
56{
57  rtems_status_code status;
58
59  Print_Warning();
60
61  TEST_BEGIN();
62
63  status = rtems_task_create(
64    rtems_build_name( 'T', 'I', 'M', 'E' ),
65    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
66    RTEMS_MINIMUM_STACK_SIZE,
67    RTEMS_DEFAULT_MODES,
68    RTEMS_DEFAULT_ATTRIBUTES,
69    &Task_id[ 1 ]
70  );
71  directive_failed( status, "rtems_task_create" );
72
73  status = rtems_task_start( Task_id[ 1 ], Test_task, 0 );
74  directive_failed( status, "rtems_task_start" );
75
76  rtems_task_exit();
77}
78
79rtems_task Test_task (
80  rtems_task_argument argument
81)
82{
83  rtems_name         name;
84  uint32_t     index;
85  void              *converted;
86
87  benchmark_timer_initialize();
88    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
89      (void) benchmark_timer_empty_function();
90  overhead = benchmark_timer_read();
91
92  name = rtems_build_name( 'P', 'O', 'R', 'T' ),
93
94  benchmark_timer_initialize();
95    rtems_port_create(
96      name,
97      Internal_area,
98      External_area,
99      0xff,
100      &Port_id
101    );
102  end_time = benchmark_timer_read();
103
104  put_time(
105    "rtems_port_create: only case",
106    end_time,
107    1,
108    0,
109    0
110  );
111
112  benchmark_timer_initialize();
113    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
114      (void) rtems_port_external_to_internal(
115               Port_id,
116               &External_area[ 0xf ],
117               &converted
118             );
119  end_time = benchmark_timer_read();
120
121  put_time(
122    "rtems_port_external_to_internal: only case",
123    end_time,
124    OPERATION_COUNT,
125    overhead,
126    0
127  );
128
129  benchmark_timer_initialize();
130    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
131      (void) rtems_port_internal_to_external(
132               Port_id,
133               &Internal_area[ 0xf ],
134               &converted
135             );
136  end_time = benchmark_timer_read();
137
138  put_time(
139    "rtems_port_internal_to_external: only case",
140    end_time,
141    OPERATION_COUNT,
142    overhead,
143    0
144  );
145
146  benchmark_timer_initialize();
147    rtems_port_delete( Port_id );
148  end_time = benchmark_timer_read();
149
150  put_time(
151    "rtems_port_delete: only case",
152    end_time,
153    1,
154    0,
155    0
156  );
157
158  TEST_END();
159  rtems_test_exit( 0 );
160}
Note: See TracBrowser for help on using the repository browser.