OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [tests/] [tmtests/] [tm08/] [task1.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.