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

4.11
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

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

  • Property mode set to 100644
File size: 4.3 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
17rtems_asr Process_asr_for_pass_1(
18  rtems_signal_set signals
19);
20
21rtems_asr Process_asr_for_pass_2(
22  rtems_signal_set signals
23);
24
25rtems_task Task_1(
26  rtems_task_argument argument
27);
28
29rtems_task Task_2(
30  rtems_task_argument argument
31);
32
33rtems_task Task_3(
34  rtems_task_argument argument
35);
36
37rtems_task Init(
38  rtems_task_argument argument
39)
40{
41  rtems_status_code status;
42
43  Print_Warning();
44
45  puts( "\n\n*** TIME TEST 19 ***" );
46
47  status = rtems_task_create(
48    rtems_build_name( 'T', 'I', 'M', 'E' ),
49    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
50    RTEMS_MINIMUM_STACK_SIZE,
51    RTEMS_DEFAULT_MODES,
52    RTEMS_DEFAULT_ATTRIBUTES,
53    &Task_id[ 1 ]
54  );
55  directive_failed( status, "rtems_task_create of TASK1" );
56
57  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
58  directive_failed( status, "rtems_task_start of TASK1" );
59
60  status = rtems_task_create(
61    rtems_build_name( 'T', 'I', 'M', 'E' ),
62    (RTEMS_MAXIMUM_PRIORITY / 2),
63    RTEMS_MINIMUM_STACK_SIZE,
64    RTEMS_DEFAULT_MODES,
65    RTEMS_DEFAULT_ATTRIBUTES,
66    &Task_id[ 2 ]
67  );
68  directive_failed( status, "rtems_task_create of TASK2" );
69
70  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
71  directive_failed( status, "rtems_task_start of TASK2" );
72
73  status = rtems_task_create(
74    rtems_build_name( 'T', 'I', 'M', 'E' ),
75    (RTEMS_MAXIMUM_PRIORITY / 2u) - 1u,
76    RTEMS_MINIMUM_STACK_SIZE,
77    RTEMS_DEFAULT_MODES,
78    RTEMS_DEFAULT_ATTRIBUTES,
79    &Task_id[ 3 ]
80  );
81  directive_failed( status, "rtems_task_create of TASK3" );
82
83  status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
84  directive_failed( status, "rtems_task_start of TASK3" );
85
86  status = rtems_task_delete( RTEMS_SELF );
87  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
88}
89
90rtems_asr Process_asr_for_pass_1(
91  rtems_signal_set signals
92)
93{
94  end_time = benchmark_timer_read();
95
96  put_time(
97    "rtems_signal_send: signal to self",
98    end_time,
99    1,
100    0,
101    CALLING_OVERHEAD_SIGNAL_SEND
102  );
103
104  benchmark_timer_initialize();
105}
106
107rtems_asr Process_asr_for_pass_2(
108  rtems_signal_set signals
109)
110{
111  rtems_status_code status;
112
113  status = rtems_task_resume( Task_id[ 3 ] );
114  directive_failed( status, "rtems_task_resume" );
115
116  benchmark_timer_initialize();
117}
118
119rtems_task Task_1(
120  rtems_task_argument argument
121)
122{
123  rtems_status_code status;
124
125  benchmark_timer_initialize();
126    (void) rtems_signal_catch( Process_asr_for_pass_1, RTEMS_DEFAULT_MODES );
127  end_time = benchmark_timer_read();
128
129  put_time(
130    "rtems_signal_catch: only case",
131    end_time,
132    1,
133    0,
134    CALLING_OVERHEAD_SIGNAL_CATCH
135  );
136
137  benchmark_timer_initialize();
138    rtems_signal_send( Task_id[ 2 ], 1 );
139  end_time = benchmark_timer_read();
140
141  put_time(
142    "rtems_signal_send: returns to caller",
143    end_time,
144    1,
145    0,
146    CALLING_OVERHEAD_SIGNAL_SEND
147  );
148
149  benchmark_timer_initialize();
150    (void) rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 );
151
152  /* end time is done is RTEMS_ASR */
153
154  end_time = benchmark_timer_read();
155
156  put_time(
157    "rtems_signal: exit ASR overhead returns to calling task",
158    end_time,
159    1,
160    0,
161    0
162  );
163
164  status = rtems_signal_catch( Process_asr_for_pass_2, RTEMS_NO_PREEMPT );
165  directive_failed( status, "rtems_signal_catch" );
166
167  benchmark_timer_initialize();
168    (void) rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 );
169}
170
171/* avoid warnings for no prototype */
172rtems_asr Process_asr_for_task_2(
173  rtems_signal_set signals
174);
175
176rtems_asr Process_asr_for_task_2(
177  rtems_signal_set signals
178)
179{
180  ;
181}
182
183rtems_task Task_2(
184  rtems_task_argument argument
185)
186{
187  rtems_status_code status;
188
189  status = rtems_signal_catch( Process_asr_for_task_2, RTEMS_DEFAULT_MODES );
190  directive_failed( status, "rtems_signal_catch" );
191
192  (void) rtems_task_suspend( RTEMS_SELF );
193}
194
195rtems_task Task_3(
196  rtems_task_argument argument
197)
198{
199  (void) rtems_task_suspend( RTEMS_SELF );
200
201  end_time = benchmark_timer_read();
202
203  put_time(
204    "rtems_signal: exit ASR overhead returns to preempting task",
205    end_time,
206    1,
207    0,
208    0
209  );
210
211  puts( "*** END OF TEST 19 ***" );
212  rtems_test_exit( 0 );
213}
Note: See TracBrowser for help on using the repository browser.