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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [tmtests/] [tm23/] [task1.c] - Blame information for rev 593

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:43 chris Exp $
11
 */
12
 
13
#define TEST_INIT
14
#include "system.h"
15
 
16
rtems_id          Timer_id[ OPERATION_COUNT+1 ];
17
 
18
rtems_time_of_day time_of_day;
19
 
20
void null_delay(
21
  rtems_id  ignored_id,
22
  void     *ignored_address
23
);
24
 
25
rtems_task Low_task(
26
  rtems_task_argument argument
27
);
28
 
29
rtems_task Middle_tasks(
30
  rtems_task_argument argument
31
);
32
 
33
rtems_task High_task(
34
  rtems_task_argument argument
35
);
36
 
37
 
38
rtems_task Init(
39
  rtems_task_argument argument
40
)
41
{
42
 
43
  rtems_task_priority priority;
44
  rtems_unsigned32    index;
45
  rtems_id            id;
46
  rtems_task_entry    task_entry;
47
  rtems_status_code   status;
48
 
49
  Print_Warning();
50
 
51
  puts( "\n\n*** TIME TEST 23 ***" );
52
 
53
  Timer_initialize();
54
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
55
      (void) Empty_function();
56
  overhead = Read_timer();
57
 
58
  priority = 5;
59
 
60
  for( index=1 ; index <= OPERATION_COUNT ; index++ ) {
61
    status = rtems_task_create(
62
      rtems_build_name( 'T', 'I', 'M', 'E' ),
63
      priority,
64
      RTEMS_MINIMUM_STACK_SIZE,
65
      RTEMS_DEFAULT_MODES,
66
      RTEMS_DEFAULT_ATTRIBUTES,
67
      &id
68
    );
69
    directive_failed( status, "rtems_task_create LOOP" );
70
 
71
    if ( index == 1 )                    task_entry = High_task;
72
    else if ( index == OPERATION_COUNT ) task_entry = Low_task;
73
    else                                 task_entry = Middle_tasks;
74
 
75
    status = rtems_task_start( id, task_entry, 0 );
76
    directive_failed( status, "rtems_task_start LOOP" );
77
 
78
    priority++;
79
  }
80
 
81
  status = rtems_task_delete( RTEMS_SELF );
82
  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
83
}
84
 
85
void null_delay(
86
  rtems_id  ignored_id,
87
  void     *ignored_address
88
)
89
{
90
}
91
 
92
rtems_task High_task(
93
  rtems_task_argument argument
94
)
95
{
96
  rtems_unsigned32  index;
97
  rtems_status_code status;
98
  int i;
99
 
100
  Timer_initialize();
101
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
102
      (void) Empty_function();
103
  overhead = Read_timer();
104
 
105
  Timer_initialize();
106
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
107
      (void) rtems_timer_create( index, &Timer_id[ index ] );
108
  end_time = Read_timer();
109
 
110
  put_time(
111
    "rtems_timer_create",
112
    end_time,
113
    OPERATION_COUNT,
114
    overhead,
115
    CALLING_OVERHEAD_TIMER_CREATE
116
  );
117
 
118
  Timer_initialize();
119
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
120
      (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL );
121
  end_time = Read_timer();
122
 
123
  put_time(
124
    "rtems_timer_fire_after: inactive",
125
    end_time,
126
    OPERATION_COUNT,
127
    overhead,
128
    CALLING_OVERHEAD_TIMER_FIRE_AFTER
129
  );
130
 
131
  Timer_initialize();
132
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
133
      (void) rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL );
134
  end_time = Read_timer();
135
 
136
  put_time(
137
    "rtems_timer_fire_after: active",
138
    end_time,
139
    OPERATION_COUNT,
140
    overhead,
141
    CALLING_OVERHEAD_TIMER_FIRE_AFTER
142
  );
143
 
144
  Timer_initialize();
145
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
146
      (void) rtems_timer_cancel( Timer_id[ index ] );
147
  end_time = Read_timer();
148
 
149
  put_time(
150
    "rtems_timer_cancel: active",
151
    end_time,
152
    OPERATION_COUNT,
153
    overhead,
154
    CALLING_OVERHEAD_TIMER_CANCEL
155
  );
156
 
157
  for ( Timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ )
158
  Timer_initialize();
159
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
160
      (void) rtems_timer_cancel( Timer_id[ index ] );
161
  end_time = Read_timer();
162
 
163
  put_time(
164
    "rtems_timer_cancel: inactive",
165
    end_time,
166
    OPERATION_COUNT,
167
    overhead,
168
    CALLING_OVERHEAD_TIMER_CANCEL
169
  );
170
 
171
  for ( Timer_initialize(), i=0 ; i<OPERATION_COUNT ; i++ )
172
  Timer_initialize();
173
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
174
      (void) rtems_timer_reset( Timer_id[ index ] );
175
  end_time = Read_timer();
176
 
177
  put_time(
178
    "rtems_timer_reset: inactive",
179
    end_time,
180
    OPERATION_COUNT,
181
    overhead,
182
    CALLING_OVERHEAD_TIMER_RESET
183
  );
184
 
185
  Timer_initialize();
186
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
187
      (void) rtems_timer_reset( Timer_id[ index ] );
188
  end_time = Read_timer();
189
 
190
  put_time(
191
    "rtems_timer_reset: active",
192
    end_time,
193
    OPERATION_COUNT,
194
    overhead,
195
    CALLING_OVERHEAD_TIMER_RESET
196
  );
197
 
198
  for ( index=1 ; index <= OPERATION_COUNT ; index++ )
199
    (void) rtems_timer_reset( Timer_id[ index ] );
200
 
201
  build_time( &time_of_day, 12, 31, 1988, 9, 0, 0, 0 );
202
 
203
  status = rtems_clock_set( &time_of_day );
204
  directive_failed( status, "rtems_clock_set" );
205
 
206
  time_of_day.year = 1989;
207
 
208
  Timer_initialize();
209
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
210
      (void) rtems_timer_fire_when(
211
         Timer_id[ index ], &time_of_day, null_delay, NULL );
212
  end_time = Read_timer();
213
 
214
  put_time(
215
    "rtems_timer_fire_when: inactive",
216
    end_time,
217
    OPERATION_COUNT,
218
    overhead,
219
    CALLING_OVERHEAD_TIMER_FIRE_WHEN
220
  );
221
 
222
  Timer_initialize();
223
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
224
      (void) rtems_timer_fire_when(
225
         Timer_id[ index ], &time_of_day, null_delay, NULL );
226
  end_time = Read_timer();
227
 
228
  put_time(
229
    "rtems_timer_fire_when: active",
230
    end_time,
231
    OPERATION_COUNT,
232
    overhead,
233
    CALLING_OVERHEAD_TIMER_FIRE_WHEN
234
  );
235
 
236
  Timer_initialize();
237
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
238
      (void) rtems_timer_delete( Timer_id[ index ] );
239
  end_time = Read_timer();
240
 
241
  put_time(
242
    "rtems_timer_delete: active",
243
    end_time,
244
    OPERATION_COUNT,
245
    overhead,
246
    CALLING_OVERHEAD_TIMER_DELETE
247
  );
248
 
249
  Timer_initialize();
250
  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
251
    status = rtems_timer_create( index, &Timer_id[ index ] );
252
    directive_failed( status, "rtems_timer_create" );
253
 
254
    status = rtems_timer_fire_after( Timer_id[ index ], 500, null_delay, NULL );
255
    directive_failed( status, "rtems_timer_fire_after" );
256
 
257
    status = rtems_timer_cancel( Timer_id[ index ] );
258
    directive_failed( status, "rtems_timer_cancel" );
259
  }
260
 
261
  Timer_initialize();
262
    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
263
      (void) rtems_timer_delete( Timer_id[ index ] );
264
  end_time = Read_timer();
265
 
266
  put_time(
267
    "rtems_timer_delete: inactive",
268
    end_time,
269
    OPERATION_COUNT,
270
    overhead,
271
    CALLING_OVERHEAD_TIMER_DELETE
272
  );
273
 
274
  Timer_initialize();
275
    (void) rtems_task_wake_when( &time_of_day );
276
}
277
 
278
rtems_task Middle_tasks(
279
  rtems_task_argument argument
280
)
281
{
282
  (void) rtems_task_wake_when( &time_of_day );
283
}
284
 
285
rtems_task Low_task(
286
  rtems_task_argument argument
287
)
288
{
289
  end_time = Read_timer();
290
 
291
  put_time(
292
    "rtems_task_wake_when",
293
    end_time,
294
    OPERATION_COUNT,
295
    0,
296
    CALLING_OVERHEAD_TASK_WAKE_WHEN
297
  );
298
 
299
  puts( "*** END OF TEST 23 ***" );
300
  exit( 0 );
301
}

powered by: WebSVN 2.1.0

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