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 | |
---|
42 | const char rtems_test_name[] = "TIME TEST 25"; |
---|
43 | |
---|
44 | rtems_id Semaphore_id; |
---|
45 | |
---|
46 | rtems_task High_tasks( |
---|
47 | rtems_task_argument argument |
---|
48 | ); |
---|
49 | |
---|
50 | rtems_task Low_task( |
---|
51 | rtems_task_argument argument |
---|
52 | ); |
---|
53 | |
---|
54 | rtems_task Init( |
---|
55 | rtems_task_argument argument |
---|
56 | ) |
---|
57 | { |
---|
58 | rtems_id task_id; |
---|
59 | uint32_t index; |
---|
60 | rtems_status_code status; |
---|
61 | |
---|
62 | Print_Warning(); |
---|
63 | |
---|
64 | TEST_BEGIN(); |
---|
65 | |
---|
66 | status = rtems_semaphore_create( |
---|
67 | rtems_build_name( 'S', 'M', '1', ' ') , |
---|
68 | 0, |
---|
69 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
70 | RTEMS_NO_PRIORITY, |
---|
71 | &Semaphore_id |
---|
72 | ); |
---|
73 | directive_failed( status, "rtems_semaphore_create of SM1" ); |
---|
74 | |
---|
75 | status = rtems_task_create( |
---|
76 | rtems_build_name( 'L', 'O', 'W', ' ' ), |
---|
77 | RTEMS_MAXIMUM_PRIORITY - 1u, |
---|
78 | RTEMS_MINIMUM_STACK_SIZE, |
---|
79 | RTEMS_DEFAULT_MODES, |
---|
80 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
81 | &task_id |
---|
82 | ); |
---|
83 | directive_failed( status, "rtems_task_create LOW" ); |
---|
84 | |
---|
85 | status = rtems_task_start( task_id, Low_task, 0 ); |
---|
86 | directive_failed( status, "rtems_task_start LOW" ); |
---|
87 | |
---|
88 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
89 | status = rtems_task_create( |
---|
90 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
91 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u, |
---|
92 | RTEMS_MINIMUM_STACK_SIZE, |
---|
93 | RTEMS_DEFAULT_MODES, |
---|
94 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
95 | &task_id |
---|
96 | ); |
---|
97 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
98 | |
---|
99 | status = rtems_task_start( task_id, High_tasks, 0 ); |
---|
100 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
101 | } |
---|
102 | |
---|
103 | rtems_task_exit(); |
---|
104 | } |
---|
105 | |
---|
106 | rtems_task High_tasks( |
---|
107 | rtems_task_argument argument |
---|
108 | ) |
---|
109 | { |
---|
110 | (void) rtems_semaphore_obtain( |
---|
111 | Semaphore_id, |
---|
112 | RTEMS_DEFAULT_OPTIONS, |
---|
113 | 0xffffffff |
---|
114 | ); |
---|
115 | } |
---|
116 | |
---|
117 | rtems_task Low_task( |
---|
118 | rtems_task_argument argument |
---|
119 | ) |
---|
120 | { |
---|
121 | benchmark_timer_initialize(); |
---|
122 | (void) rtems_clock_tick(); |
---|
123 | end_time = benchmark_timer_read(); |
---|
124 | |
---|
125 | put_time( |
---|
126 | "rtems_clock_tick: only case", |
---|
127 | end_time, |
---|
128 | 1, |
---|
129 | 0, |
---|
130 | 0 |
---|
131 | ); |
---|
132 | |
---|
133 | TEST_END(); |
---|
134 | rtems_test_exit( 0 ); |
---|
135 | } |
---|