source: rtems/testsuites/tmtests/tm08/task1.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 5.9 KB
RevLine 
[ac7d5ef0]1/*
[9410d011]2 *  COPYRIGHT (c) 1989-2013.
[ac7d5ef0]3 *  On-Line Applications Research Corporation (OAR).
4 *
[98e4ebf5]5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
[c499856]7 *  http://www.rtems.org/license/LICENSE.
[ac7d5ef0]8 */
9
[a4bc4d6e]10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
[d1128e2]14#define CONFIGURE_INIT
[ac7d5ef0]15#include "system.h"
16
17rtems_id Test_task_id;
18
19rtems_task test_task(
20  rtems_task_argument argument
21);
22rtems_task test_task1(
23  rtems_task_argument argument
24);
[1055ce20]25void test_init(void);
[ac7d5ef0]26
27rtems_task Init(
28  rtems_task_argument argument
29)
30{
31  rtems_status_code status;
32
[3a4ae6c]33  Print_Warning();
34
[ac7d5ef0]35  puts( "\n\n*** TIME TEST 8 ***" );
36
37  test_init();
38
39  status = rtems_task_delete( RTEMS_SELF );
40  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
41}
42
[1055ce20]43void test_init(void)
[ac7d5ef0]44{
45  rtems_status_code status;
46
47  status = rtems_task_create(
48    1,
[1055ce20]49    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
[3652ad35]50    RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]51    RTEMS_DEFAULT_MODES,
52    RTEMS_DEFAULT_ATTRIBUTES,
53    &Test_task_id
54  );
55  directive_failed( status, "rtems_task_create" );
56
57  status = rtems_task_start( Test_task_id, test_task, 0 );
58  directive_failed( status, "rtems_task_start" );
59
60  status = rtems_task_create(
61    1,
[1055ce20]62    RTEMS_MAXIMUM_PRIORITY - 1u,
[3652ad35]63    RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]64    RTEMS_DEFAULT_MODES,
65    RTEMS_DEFAULT_ATTRIBUTES,
66    &Test_task_id
67  );
68  directive_failed( status, "rtems_task_create" );
69
70  status = rtems_task_start( Test_task_id, test_task1, 0 );
71  directive_failed( status, "rtems_task_start" );
72}
73
74rtems_task test_task(
75  rtems_task_argument argument
76)
77{
78  rtems_status_code   status;
[0720ff4]79  uint32_t      index;
[ac7d5ef0]80  rtems_task_priority old_priority;
81  rtems_time_of_day   time;
[0720ff4]82  uint32_t      old_note;
83  uint32_t      old_mode;
[ac7d5ef0]84
[dbf4f17]85  benchmark_timer_initialize();
[ac7d5ef0]86    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
[dbf4f17]87      (void) benchmark_timer_empty_function();
88  overhead = benchmark_timer_read();
[ac7d5ef0]89
[dbf4f17]90  benchmark_timer_initialize();
[ac7d5ef0]91    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
92      (void) rtems_task_set_priority(
93               Test_task_id,
94               RTEMS_CURRENT_PRIORITY,
95               &old_priority
96             );
[dbf4f17]97  end_time = benchmark_timer_read();
[ac7d5ef0]98
99  put_time(
[5c491aef]100    "rtems_task_set_priority: obtain current priority",
[ac7d5ef0]101    end_time,
102    OPERATION_COUNT,
103    overhead,
104    CALLING_OVERHEAD_TASK_SET_PRIORITY
105  );
106
[dbf4f17]107  benchmark_timer_initialize();
[ac7d5ef0]108    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
[4389287a]109      (void) rtems_task_set_priority(
[b1274bd9]110        Test_task_id,
[1055ce20]111        RTEMS_MAXIMUM_PRIORITY - 2u,
[4389287a]112        &old_priority
113      );
[b1274bd9]114
[dbf4f17]115  end_time = benchmark_timer_read();
[ac7d5ef0]116
117  put_time(
[5c491aef]118    "rtems_task_set_priority: returns to caller",
[ac7d5ef0]119    end_time,
120    OPERATION_COUNT,
121    overhead,
122    CALLING_OVERHEAD_TASK_SET_PRIORITY
123  );
124
[dbf4f17]125  benchmark_timer_initialize();
[ac7d5ef0]126    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
127      (void) rtems_task_mode(
128        RTEMS_CURRENT_MODE,
129        RTEMS_CURRENT_MODE,
130        &old_mode
131      );
[dbf4f17]132  end_time = benchmark_timer_read();
[ac7d5ef0]133
134  put_time(
[5c491aef]135    "rtems_task_mode: obtain current mode",
[ac7d5ef0]136    end_time,
137    OPERATION_COUNT,
138    overhead,
139    CALLING_OVERHEAD_TASK_MODE
140  );
141
[dbf4f17]142  benchmark_timer_initialize();
[ac7d5ef0]143    for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
144      (void) rtems_task_mode(
145        RTEMS_INTERRUPT_LEVEL(1),
146        RTEMS_INTERRUPT_MASK,
147        &old_mode
148      );
149      (void) rtems_task_mode(
150        RTEMS_INTERRUPT_LEVEL(0),
151        RTEMS_INTERRUPT_MASK,
152        &old_mode
153      );
154    }
[dbf4f17]155  end_time = benchmark_timer_read();
[ac7d5ef0]156
157  put_time(
[5c491aef]158    "rtems_task_mode: no reschedule",
[ac7d5ef0]159    end_time,
160    OPERATION_COUNT * 2,
161    overhead,
162    CALLING_OVERHEAD_TASK_MODE
163  );
164
[dbf4f17]165  benchmark_timer_initialize();                 /* must be one host */
[ac7d5ef0]166    (void) rtems_task_mode( RTEMS_NO_ASR, RTEMS_ASR_MASK, &old_mode );
[dbf4f17]167  end_time = benchmark_timer_read();
[ac7d5ef0]168
169  put_time(
[9410d011]170    "rtems_task_mode: reschedule returns to caller",
[ac7d5ef0]171    end_time,
172    1,
173    0,
174    CALLING_OVERHEAD_TASK_MODE
175  );
176
177  status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
178  directive_failed( status, "rtems_task_mode" );
179
180  status = rtems_task_set_priority( Test_task_id, 1, &old_priority );
181  directive_failed( status, "rtems_task_set_priority" );
182
183  /* preempted by test_task1 */
[dbf4f17]184  benchmark_timer_initialize();
[ac7d5ef0]185    (void)  rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode );
186
[dbf4f17]187  benchmark_timer_initialize();
[ac7d5ef0]188    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
189      (void) rtems_task_set_note( Test_task_id, 8, 10 );
[dbf4f17]190  end_time = benchmark_timer_read();
[ac7d5ef0]191
192  put_time(
[9410d011]193    "rtems_task_set_note: only case",
[ac7d5ef0]194    end_time,
195    OPERATION_COUNT,
196    overhead,
197    CALLING_OVERHEAD_TASK_SET_NOTE
198  );
199
[dbf4f17]200  benchmark_timer_initialize();
[ac7d5ef0]201    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
202      (void) rtems_task_get_note( Test_task_id, 8, &old_note );
[dbf4f17]203  end_time = benchmark_timer_read();
[ac7d5ef0]204
205  put_time(
[9410d011]206    "rtems_task_get_note: only case",
[ac7d5ef0]207    end_time,
208    OPERATION_COUNT,
209    overhead,
210    CALLING_OVERHEAD_TASK_GET_NOTE
211  );
212
213  build_time( &time, 1, 1, 1988, 0, 0, 0, 0 );
214
[dbf4f17]215  benchmark_timer_initialize();
[ac7d5ef0]216    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
217      (void) rtems_clock_set( &time );
[dbf4f17]218  end_time = benchmark_timer_read();
[ac7d5ef0]219
220  put_time(
[9410d011]221    "rtems_clock_set: only case",
[ac7d5ef0]222    end_time,
223    OPERATION_COUNT,
224    overhead,
225    CALLING_OVERHEAD_CLOCK_SET
226  );
227
[dbf4f17]228  benchmark_timer_initialize();
[ac7d5ef0]229    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
[ec5c898]230      (void) rtems_clock_get_tod( &time );
[dbf4f17]231  end_time = benchmark_timer_read();
[ac7d5ef0]232
233  put_time(
[9410d011]234    "rtems_clock_get_tod: only case",
[ac7d5ef0]235    end_time,
236    OPERATION_COUNT,
237    overhead,
238    CALLING_OVERHEAD_CLOCK_GET
239  );
240
[3a4ae6c]241  puts( "*** END OF TEST 8 ***" );
[b454bc9]242  rtems_test_exit( 0 );
[ac7d5ef0]243}
244
245rtems_task test_task1(
246  rtems_task_argument argument
247)
248{
[dbf4f17]249  end_time = benchmark_timer_read();
[ac7d5ef0]250
251  put_time(
[5c491aef]252    "rtems_task_mode: reschedule -- preempts caller",
[ac7d5ef0]253    end_time,
254    1,
255    0,
256    CALLING_OVERHEAD_TASK_MODE
257  );
258
259  (void) rtems_task_suspend( RTEMS_SELF );
260}
Note: See TracBrowser for help on using the repository browser.