source: rtems/testsuites/tmtests/tm20/task1.c @ 3a4ae6c

4.104.114.84.95
Last change on this file since 3a4ae6c was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/95 at 19:35:39

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 9.8 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
4 *  On-Line Applications Research Corporation (OAR).
5 *  All rights assigned to U.S. Government, 1994.
6 *
7 *  This material may be reproduced by or for the U.S. Government pursuant
8 *  to the copyright license under the clause at DFARS 252.227-7013.  This
9 *  notice must appear in all copies of this file and its derivatives.
10 *
11 *  $Id$
12 */
13
14#define TEST_INIT
15#include "system.h"
16
17rtems_device_major_number _STUB_major = 1;
18
19rtems_id         Region_id;
20rtems_name       Region_name;
21rtems_unsigned8  Region_area[ 2048 ] CPU_STRUCTURE_ALIGNMENT;
22
23rtems_id         Partition_id;
24rtems_name       Partition_name;
25rtems_unsigned8  Partition_area[ 2048 ] CPU_STRUCTURE_ALIGNMENT;
26
27void            *Buffer_address_1;
28void            *Buffer_address_2;
29void            *Buffer_address_3;
30void            *Buffer_address_4;
31
32rtems_unsigned32 buffer_count;
33
34void            *Buffer_addresses[ OPERATION_COUNT+1 ];
35
36rtems_task Task_1(
37  rtems_task_argument argument
38);
39
40rtems_task Task_2(
41  rtems_task_argument argument
42);
43
44rtems_task Init(
45  rtems_task_argument argument
46)
47{
48  rtems_status_code status;
49
50  Print_Warning();
51
52  puts( "\n\n*** TIME TEST 20 ***" );
53
54  status = rtems_task_create(
55    rtems_build_name( 'T', 'I', 'M', '1' ),
56    128,
57    2048,
58    RTEMS_DEFAULT_MODES,
59    RTEMS_DEFAULT_ATTRIBUTES,
60    &Task_id[ 1 ]
61  );
62  directive_failed( status, "rtems_task_create of TASK1" );
63
64  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
65  directive_failed( status, "rtems_task_start of TASK1" );
66
67  status = rtems_task_create(
68    rtems_build_name( 'T', 'I', 'M', '2' ),
69    129,
70    2048,
71    RTEMS_DEFAULT_MODES,
72    RTEMS_DEFAULT_ATTRIBUTES,
73    &Task_id[ 2 ]
74  );
75  directive_failed( status, "rtems_task_create of TASK2" );
76
77  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
78  directive_failed( status, "rtems_task_start of TASK2" );
79
80  status = rtems_task_delete( RTEMS_SELF );
81  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
82}
83
84rtems_task Task_1(
85  rtems_task_argument argument
86)
87{
88  rtems_unsigned32    index;
89  rtems_mode          previous_mode;
90  rtems_task_priority previous_priority;
91  rtems_status_code   status;
92
93  Partition_name = rtems_build_name( 'P', 'A', 'R', 'T' );
94
95  Timer_initialize();
96    rtems_partition_create(
97      Partition_name,
98      Partition_area,
99      2048,
100      128,
101      RTEMS_DEFAULT_ATTRIBUTES,
102      &Partition_id
103    );
104  end_time = Read_timer();
105
106  put_time(
107    "rtems_partition_create",
108    end_time,
109    1,
110    0,
111    CALLING_OVERHEAD_PARTITION_CREATE
112  );
113
114  Region_name = rtems_build_name( 'R', 'E', 'G', 'N' );
115
116  Timer_initialize();
117    rtems_region_create(
118      Region_name,
119      Region_area,
120      2048,
121      16,
122      RTEMS_DEFAULT_ATTRIBUTES,
123      &Region_id
124    );
125  end_time = Read_timer();
126
127  put_time(
128    "rtems_region_create",
129    end_time,
130    1,
131    0,
132    CALLING_OVERHEAD_REGION_CREATE
133  );
134
135  Timer_initialize();
136    (void) rtems_partition_get_buffer( Partition_id, &Buffer_address_1 );
137  end_time = Read_timer();
138
139  put_time(
140    "rtems_partition_get_buffer (available)",
141    end_time,
142    1,
143    0,
144    CALLING_OVERHEAD_PARTITION_GET_BUFFER
145  );
146
147  buffer_count = 0;
148  while ( FOREVER ) {
149
150    status = rtems_partition_get_buffer(
151               Partition_id,
152               &Buffer_addresses[ buffer_count ]
153            );
154
155    if ( status == RTEMS_UNSATISFIED ) break;
156
157    buffer_count++;
158  }
159
160  Timer_initialize();
161    (void) rtems_partition_get_buffer( Partition_id, &Buffer_address_2 );
162  end_time = Read_timer();
163
164  put_time(
165    "rtems_partition_get_buffer (not available)",
166    end_time,
167    1,
168    0,
169    CALLING_OVERHEAD_PARTITION_GET_BUFFER
170  );
171
172  Timer_initialize();
173    (void) rtems_partition_return_buffer( Partition_id, Buffer_address_1 );
174  end_time = Read_timer();
175
176  put_time(
177    "rtems_partition_return_buffer",
178    end_time,
179    1,
180    0,
181    CALLING_OVERHEAD_PARTITION_RETURN_BUFFER
182  );
183
184  for ( index = 0 ; index < buffer_count ; index++ ) {
185
186    status = rtems_partition_return_buffer(
187               Partition_id,
188               Buffer_addresses[ index ]
189             );
190    directive_failed( status, "rtems_partition_return_buffer" );
191
192  }
193
194  Timer_initialize();
195    (void) rtems_partition_delete( Partition_id );
196  end_time = Read_timer();
197
198  put_time(
199    "rtems_partition_delete",
200    end_time,
201    1,
202    0,
203    CALLING_OVERHEAD_PARTITION_DELETE
204  );
205
206  status = rtems_region_get_segment(
207             Region_id,
208             400,
209             RTEMS_DEFAULT_OPTIONS,
210             RTEMS_NO_TIMEOUT,
211             &Buffer_address_2
212           );
213  directive_failed( status, "region_get_semgent" );
214
215  Timer_initialize();
216    (void) rtems_region_get_segment(
217      Region_id,
218      400,
219      RTEMS_DEFAULT_OPTIONS,
220      RTEMS_NO_TIMEOUT,
221      &Buffer_address_3
222    );
223  end_time = Read_timer();
224
225  put_time(
226    "rtems_region_get_segment (available)",
227    end_time,
228    1,
229    0,
230    CALLING_OVERHEAD_REGION_GET_SEGMENT
231  );
232
233  Timer_initialize();
234    (void) rtems_region_get_segment(
235      Region_id,
236      1998,
237      RTEMS_NO_WAIT,
238      RTEMS_NO_TIMEOUT,
239      &Buffer_address_4
240    );
241  end_time = Read_timer();
242
243  put_time(
244    "rtems_region_get_segment (RTEMS_NO_WAIT)",
245    end_time,
246    1,
247    0,
248    CALLING_OVERHEAD_REGION_GET_SEGMENT
249  );
250
251  status = rtems_region_return_segment( Region_id, Buffer_address_3 );
252  directive_failed( status, "rtems_region_return_segment" );
253
254  Timer_initialize();
255    (void) rtems_region_return_segment( Region_id, Buffer_address_2 );
256  end_time = Read_timer();
257
258  put_time(
259    "rtems_region_return_segment (no tasks waiting)",
260    end_time,
261    1,
262    0,
263    CALLING_OVERHEAD_REGION_RETURN_SEGMENT
264  );
265
266  status = rtems_region_get_segment(
267    Region_id,
268    400,
269    RTEMS_DEFAULT_OPTIONS,
270    RTEMS_NO_TIMEOUT,
271    &Buffer_address_1
272  );
273  directive_failed( status, "rtems_region_get_segment" );
274
275  Timer_initialize();
276    (void) rtems_region_get_segment(
277      Region_id,
278      1998,
279      RTEMS_DEFAULT_OPTIONS,
280      RTEMS_NO_TIMEOUT,
281      &Buffer_address_2
282    );
283
284  /* execute Task_2 */
285
286  end_time = Read_timer();
287
288  put_time(
289    "rtems_region_return_segment (preempt)",
290    end_time,
291    1,
292    0,
293    CALLING_OVERHEAD_REGION_RETURN_SEGMENT
294  );
295
296  status = rtems_region_return_segment( Region_id, Buffer_address_2 );
297  directive_failed( status, "rtems_region_return_segment" );
298
299  status = rtems_task_mode(
300    RTEMS_NO_PREEMPT,
301    RTEMS_PREEMPT_MASK,
302    &previous_mode
303  );
304  directive_failed( status, "rtems_task_mode" );
305
306  status = rtems_task_set_priority( RTEMS_SELF, 254, &previous_priority );
307  directive_failed( status, "rtems_task_set_priority" );
308
309  status = rtems_region_get_segment(
310    Region_id,
311    400,
312    RTEMS_DEFAULT_OPTIONS,
313    RTEMS_NO_TIMEOUT,
314    &Buffer_address_1
315  );
316  directive_failed( status, "rtems_region_return_segment" );
317
318  status = rtems_region_get_segment(
319    Region_id,
320    1998,
321    RTEMS_DEFAULT_OPTIONS,
322    RTEMS_NO_TIMEOUT,
323    &Buffer_address_2
324  );
325  directive_failed( status, "rtems_region_get_segment" );
326
327  /* execute Task_2 */
328
329  status = rtems_region_return_segment( Region_id, Buffer_address_2 );
330  directive_failed( status, "rtems_region_return_segment" );
331
332  Timer_initialize();
333    (void) rtems_region_delete( Region_id );
334  end_time = Read_timer();
335
336  put_time(
337    "rtems_region_delete",
338    end_time,
339    1,
340    0,
341    CALLING_OVERHEAD_REGION_DELETE
342  );
343
344  Timer_initialize();
345    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
346      (void) Empty_function();
347  overhead = Read_timer();
348
349  Timer_initialize();
350    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
351      (void) rtems_io_initialize( 0, 0, NULL );
352  end_time = Read_timer();
353
354  put_time(
355    "rtems_io_initialize",
356    end_time,
357    OPERATION_COUNT,
358    overhead,
359    CALLING_OVERHEAD_IO_INITIALIZE
360  );
361
362  Timer_initialize();
363    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
364      (void) rtems_io_open( 0, 0, NULL );
365  end_time = Read_timer();
366
367  put_time(
368    "rtems_io_open",
369    end_time,
370    OPERATION_COUNT,
371    overhead,
372    CALLING_OVERHEAD_IO_OPEN
373  );
374
375  Timer_initialize();
376    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
377      (void) rtems_io_close( 0, 0, NULL );
378  end_time = Read_timer();
379
380  put_time(
381    "rtems_io_close",
382    end_time,
383    OPERATION_COUNT,
384    overhead,
385    CALLING_OVERHEAD_IO_CLOSE
386  );
387
388  Timer_initialize();
389    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
390      (void) rtems_io_read( 0, 0, NULL );
391  end_time = Read_timer();
392
393  put_time(
394    "rtems_io_read",
395    end_time,
396    OPERATION_COUNT,
397    overhead,
398    CALLING_OVERHEAD_IO_READ
399  );
400
401  Timer_initialize();
402    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
403      (void) rtems_io_write( 0, 0, NULL );
404  end_time = Read_timer();
405
406  put_time(
407    "rtems_io_write",
408    end_time,
409    OPERATION_COUNT,
410    overhead,
411    CALLING_OVERHEAD_IO_WRITE
412  );
413
414  Timer_initialize();
415    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
416      (void) rtems_io_control( 0, 0, NULL );
417  end_time = Read_timer();
418
419  put_time(
420    "rtems_io_control",
421    end_time,
422    OPERATION_COUNT,
423    overhead,
424    CALLING_OVERHEAD_IO_CONTROL
425  );
426
427  puts( "*** END OF TEST 20 ***" );
428  exit( 0 );
429}
430
431rtems_task Task_2(
432  rtems_task_argument argument
433)
434{
435  rtems_status_code status;
436
437  end_time = Read_timer();
438
439  put_time(
440    "rtems_region_get_segment (blocking)",
441    end_time,
442    1,
443    0,
444    CALLING_OVERHEAD_REGION_GET_SEGMENT
445  );
446
447  Timer_initialize();
448    (void) rtems_region_return_segment( Region_id, Buffer_address_1 );
449
450  /* preempt back to Task_1 */
451
452  Timer_initialize();
453    (void) rtems_region_return_segment( Region_id, Buffer_address_1 );
454  end_time = Read_timer();
455
456  put_time(
457    "rtems_region_return_segment (ready -- return)",
458    end_time,
459    1,
460    0,
461    CALLING_OVERHEAD_REGION_RETURN_SEGMENT
462  );
463
464  status = rtems_task_delete( RTEMS_SELF );
465  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
466}
Note: See TracBrowser for help on using the repository browser.