source: rtems/testsuites/tmtests/tm20/task1.c @ 95a81ab

4.104.114.84.9
Last change on this file since 95a81ab was 95a81ab, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2003 at 6:53:55 PM

2003-09-04 Joel Sherrill <joel@…>

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