source: rtems/testsuites/tmtests/tm03/tm03impl.h @ 34cbac1

5
Last change on this file since 34cbac1 was 34cbac1, checked in by Sebastian Huber <sebastian.huber@…>, on 11/06/19 at 15:18:03

tmtests: Avoid build system defined defines

Update #3818.

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