source: rtems/testsuites/tmtests/tm08/task1.c @ 1307e75

5
Last change on this file since 1307e75 was 1307e75, checked in by Joel Sherrill <joel@…>, on 12/08/17 at 18:15:12

tm08: Do not use RTEMS_INTERRUPT_MASK for no reschedule case

Updates #3000.

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
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#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16
17const char rtems_test_name[] = "TIME TEST 8";
18
19rtems_id Test_task_id;
20
21rtems_task test_task(
22  rtems_task_argument argument
23);
24rtems_task test_task1(
25  rtems_task_argument argument
26);
27void test_init(void);
28
29rtems_task Init(
30  rtems_task_argument argument
31)
32{
33  rtems_status_code status;
34
35  Print_Warning();
36
37  TEST_BEGIN();
38
39  test_init();
40
41  status = rtems_task_delete( RTEMS_SELF );
42  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
43}
44
45void test_init(void)
46{
47  rtems_status_code status;
48
49  status = rtems_task_create(
50    1,
51    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
52    RTEMS_MINIMUM_STACK_SIZE,
53    RTEMS_DEFAULT_MODES,
54    RTEMS_DEFAULT_ATTRIBUTES,
55    &Test_task_id
56  );
57  directive_failed( status, "rtems_task_create" );
58
59  status = rtems_task_start( Test_task_id, test_task, 0 );
60  directive_failed( status, "rtems_task_start" );
61
62  status = rtems_task_create(
63    1,
64    RTEMS_MAXIMUM_PRIORITY - 1u,
65    RTEMS_MINIMUM_STACK_SIZE,
66    RTEMS_DEFAULT_MODES,
67    RTEMS_DEFAULT_ATTRIBUTES,
68    &Test_task_id
69  );
70  directive_failed( status, "rtems_task_create" );
71
72  status = rtems_task_start( Test_task_id, test_task1, 0 );
73  directive_failed( status, "rtems_task_start" );
74}
75
76rtems_task test_task(
77  rtems_task_argument argument
78)
79{
80  rtems_status_code   status;
81  uint32_t            index;
82  rtems_task_priority old_priority;
83  rtems_time_of_day   time;
84  rtems_mode          old_mode;
85  rtems_mode          desired_mode;
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  benchmark_timer_initialize();
93    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
94      (void) rtems_task_set_priority(
95               Test_task_id,
96               RTEMS_CURRENT_PRIORITY,
97               &old_priority
98             );
99  end_time = benchmark_timer_read();
100
101  put_time(
102    "rtems_task_set_priority: obtain current priority",
103    end_time,
104    OPERATION_COUNT,
105    overhead,
106    0
107  );
108
109  benchmark_timer_initialize();
110    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
111      (void) rtems_task_set_priority(
112        Test_task_id,
113        RTEMS_MAXIMUM_PRIORITY - 2u,
114        &old_priority
115      );
116
117  end_time = benchmark_timer_read();
118
119  put_time(
120    "rtems_task_set_priority: returns to caller",
121    end_time,
122    OPERATION_COUNT,
123    overhead,
124    0
125  );
126
127  benchmark_timer_initialize();
128    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
129      (void) rtems_task_mode(
130        RTEMS_CURRENT_MODE,
131        RTEMS_CURRENT_MODE,
132        &old_mode
133      );
134  end_time = benchmark_timer_read();
135
136  put_time(
137    "rtems_task_mode: obtain current mode",
138    end_time,
139    OPERATION_COUNT,
140    overhead,
141    0
142  );
143
144  desired_mode = old_mode;
145
146  benchmark_timer_initialize();
147    for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
148      (void) rtems_task_mode(
149        RTEMS_TIMESLICE_MASK,
150        desired_mode,
151        &old_mode
152      );
153      (void) rtems_task_mode(
154        RTEMS_TIMESLICE_MASK,
155        desired_mode,
156        &old_mode
157      );
158    }
159  end_time = benchmark_timer_read();
160
161  put_time(
162    "rtems_task_mode: no reschedule",
163    end_time,
164    OPERATION_COUNT * 2,
165    overhead,
166    0
167  );
168
169  benchmark_timer_initialize();                 /* must be one host */
170    (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode );
171  end_time = benchmark_timer_read();
172
173  put_time(
174    "rtems_task_mode: reschedule returns to caller",
175    end_time,
176    1,
177    0,
178    0
179  );
180
181  status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
182  directive_failed( status, "rtems_task_mode" );
183
184  status = rtems_task_set_priority( Test_task_id, 1, &old_priority );
185  directive_failed( status, "rtems_task_set_priority" );
186
187  /* preempted by test_task1 */
188  benchmark_timer_initialize();
189    (void) rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
190
191  build_time( &time, 1, 1, 1988, 0, 0, 0, 0 );
192
193  benchmark_timer_initialize();
194    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
195      (void) rtems_clock_set( &time );
196  end_time = benchmark_timer_read();
197
198  put_time(
199    "rtems_clock_set: only case",
200    end_time,
201    OPERATION_COUNT,
202    overhead,
203    0
204  );
205
206  benchmark_timer_initialize();
207    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
208      (void) rtems_clock_get_tod( &time );
209  end_time = benchmark_timer_read();
210
211  put_time(
212    "rtems_clock_get_tod: only case",
213    end_time,
214    OPERATION_COUNT,
215    overhead,
216    0
217  );
218
219  TEST_END();
220  rtems_test_exit( 0 );
221}
222
223rtems_task test_task1(
224  rtems_task_argument argument
225)
226{
227  end_time = benchmark_timer_read();
228
229  put_time(
230    "rtems_task_mode: reschedule -- preempts caller",
231    end_time,
232    1,
233    0,
234    0
235  );
236
237  (void) rtems_task_suspend( RTEMS_SELF );
238}
Note: See TracBrowser for help on using the repository browser.