1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /* |
---|
4 | * COPYRIGHT (c) 1989-2009. |
---|
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 | |
---|
42 | const char rtems_test_name[] = "TIME TEST 18"; |
---|
43 | |
---|
44 | uint32_t taskcount; |
---|
45 | rtems_task_priority taskpri; |
---|
46 | |
---|
47 | extern void test_init(void); |
---|
48 | |
---|
49 | rtems_task First_task( |
---|
50 | rtems_task_argument argument |
---|
51 | ); |
---|
52 | |
---|
53 | rtems_task Middle_tasks( |
---|
54 | rtems_task_argument argument |
---|
55 | ); |
---|
56 | |
---|
57 | rtems_task Last_task( |
---|
58 | rtems_task_argument argument |
---|
59 | ); |
---|
60 | |
---|
61 | |
---|
62 | rtems_task Init( |
---|
63 | rtems_task_argument argument |
---|
64 | ) |
---|
65 | { |
---|
66 | Print_Warning(); |
---|
67 | |
---|
68 | TEST_BEGIN(); |
---|
69 | |
---|
70 | test_init(); |
---|
71 | |
---|
72 | rtems_task_exit(); |
---|
73 | } |
---|
74 | |
---|
75 | void test_init(void) |
---|
76 | { |
---|
77 | rtems_id id; |
---|
78 | rtems_task_entry task_entry; |
---|
79 | uint32_t index; |
---|
80 | rtems_status_code status; |
---|
81 | |
---|
82 | for ( index = 0 ; index <= OPERATION_COUNT ; index++ ) { |
---|
83 | status = rtems_task_create( |
---|
84 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
85 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u, |
---|
86 | RTEMS_MINIMUM_STACK_SIZE, |
---|
87 | RTEMS_DEFAULT_MODES, |
---|
88 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
89 | &id |
---|
90 | ); |
---|
91 | directive_failed( status, "rtems_task_create loop" ); |
---|
92 | |
---|
93 | if ( index == OPERATION_COUNT ) task_entry = Last_task; |
---|
94 | else if ( index == 0 ) task_entry = First_task; |
---|
95 | else task_entry = Middle_tasks; |
---|
96 | |
---|
97 | |
---|
98 | status = rtems_task_start( id, task_entry, 0 ); |
---|
99 | directive_failed( status, "rtems_task_start loop" ); |
---|
100 | } |
---|
101 | |
---|
102 | } |
---|
103 | |
---|
104 | rtems_task First_task( |
---|
105 | rtems_task_argument argument |
---|
106 | ) |
---|
107 | { |
---|
108 | benchmark_timer_initialize(); |
---|
109 | |
---|
110 | rtems_task_exit(); |
---|
111 | } |
---|
112 | |
---|
113 | rtems_task Middle_tasks( |
---|
114 | rtems_task_argument argument |
---|
115 | ) |
---|
116 | { |
---|
117 | rtems_task_exit(); |
---|
118 | } |
---|
119 | |
---|
120 | rtems_task Last_task( |
---|
121 | rtems_task_argument argument |
---|
122 | ) |
---|
123 | { |
---|
124 | end_time = benchmark_timer_read(); |
---|
125 | |
---|
126 | put_time( |
---|
127 | "rtems_task_delete: calling task", |
---|
128 | end_time, |
---|
129 | OPERATION_COUNT, |
---|
130 | 0, |
---|
131 | 0 |
---|
132 | ); |
---|
133 | |
---|
134 | TEST_END(); |
---|
135 | rtems_test_exit( 0 ); |
---|
136 | } |
---|