source: rtems/testsuites/tmtests/tm03/tm03impl.h @ fdeaa64

5
Last change on this file since fdeaa64 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: 4.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2014.
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
23#if defined(TM03)
24const char rtems_test_name[] = "TIME TEST 3";
25#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO)
26#define ATTR_DESC "counting/FIFO"
27
28#elif defined(TM32)
29const char rtems_test_name[] = "TIME TEST 32";
30#define SEMAPHORE_ATTRIBUTES (RTEMS_COUNTING_SEMAPHORE | RTEMS_PRIORITY)
31#define ATTR_DESC "counting/priority"
32
33#elif defined(TM34)
34const char rtems_test_name[] = "TIME TEST 34";
35#define SEMAPHORE_ATTRIBUTES RTEMS_BINARY_SEMAPHORE
36#define ATTR_DESC "binary/FIFO"
37
38#elif defined(TM36)
39const char rtems_test_name[] = "TIME TEST 36";
40#define SEMAPHORE_ATTRIBUTES (RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY)
41#define ATTR_DESC "binary/priority"
42
43#else
44#error "Unknown test configuration"
45#endif
46
47
48rtems_id Semaphore_id;
49rtems_task test_init(
50  rtems_task_argument argument
51);
52
53rtems_task Middle_tasks(
54  rtems_task_argument argument
55);
56
57rtems_task High_task(
58  rtems_task_argument argument
59);
60
61int operation_count = OPERATION_COUNT;
62
63rtems_task Init(
64  rtems_task_argument argument
65)
66{
67  rtems_status_code status;
68  rtems_id          task_id;
69
70  Print_Warning();
71
72  TEST_BEGIN();
73  status = rtems_task_create(
74    rtems_build_name( 'T', 'A', '1', ' ' ),
75    RTEMS_MAXIMUM_PRIORITY - 1u,
76    RTEMS_MINIMUM_STACK_SIZE,
77    RTEMS_DEFAULT_MODES,
78    RTEMS_DEFAULT_ATTRIBUTES,
79    &task_id
80  );
81  directive_failed( status, "rtems_task_create of test_init" );
82
83  status = rtems_task_start( task_id, test_init, 0 );
84  directive_failed( status, "rtems_task_start of test_init" );
85
86  rtems_task_exit();
87}
88
89rtems_task test_init(
90  rtems_task_argument argument
91)
92{
93  rtems_status_code   status;
94  int                 index;
95  rtems_id            task_id;
96  rtems_task_priority priority;
97
98  priority = RTEMS_MAXIMUM_PRIORITY - 2u;
99
100  status = rtems_semaphore_create(
101    rtems_build_name( 'S', 'M', '1', '\0'),
102    0,
103    SEMAPHORE_ATTRIBUTES,
104    RTEMS_NO_PRIORITY,
105    &Semaphore_id
106  );
107  directive_failed( status, "rtems_semaphore_create of SM1" );
108
109  if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2u )
110    operation_count =  (int) (RTEMS_MAXIMUM_PRIORITY - 2u);
111  for ( index = 2 ; index < operation_count ; index ++ ) {
112    rtems_task_create(
113      rtems_build_name( 'M', 'I', 'D', ' ' ),
114      priority,
115      RTEMS_MINIMUM_STACK_SIZE,
116      RTEMS_DEFAULT_MODES,
117      RTEMS_DEFAULT_ATTRIBUTES,
118      &task_id
119    );
120    directive_failed( status, "rtems_task_create middle" );
121
122    priority--;
123
124    rtems_task_start( task_id, Middle_tasks, 0 );
125    directive_failed( status, "rtems_task_start middle" );
126  }
127
128  status = rtems_task_create(
129    rtems_build_name( 'H', 'I', 'G', 'H' ),
130    priority,
131    RTEMS_MINIMUM_STACK_SIZE,
132    RTEMS_DEFAULT_MODES,
133    RTEMS_DEFAULT_ATTRIBUTES,
134    &task_id
135  );
136  directive_failed( status, "rtems_task_create of high task" );
137
138  status = rtems_task_start( task_id, High_task, 0 );
139  directive_failed( status, "rtems_task_start of high task" );
140
141  benchmark_timer_initialize();                          /* start the timer */
142  status = rtems_semaphore_release( Semaphore_id );
143}
144
145rtems_task Middle_tasks(
146  rtems_task_argument argument
147)
148{
149  (void) rtems_semaphore_obtain(
150    Semaphore_id,
151    RTEMS_DEFAULT_OPTIONS,
152    RTEMS_NO_TIMEOUT
153  );
154
155  (void) rtems_semaphore_release( Semaphore_id );
156}
157
158rtems_task High_task(
159  rtems_task_argument argument
160)
161{
162  (void) rtems_semaphore_obtain(
163    Semaphore_id,
164    RTEMS_DEFAULT_OPTIONS,
165    RTEMS_NO_TIMEOUT
166  );
167
168  end_time = benchmark_timer_read();
169
170  put_time(
171    "rtems_semaphore_release: " ATTR_DESC " task readied preempts caller",
172    end_time,
173    operation_count - 1,
174    0,
175    0
176  );
177
178  TEST_END();
179  rtems_test_exit( 0 );
180}
Note: See TracBrowser for help on using the repository browser.