source: rtems/testsuites/tmtests/tmck/task1.c @ 0720ff4

4.104.114.84.9
Last change on this file since 0720ff4 was 0720ff4, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 28, 2004 at 7:20:11 AM

2004-03-28 Ralf Corsepius <ralf_corsepius@…>

  • include/timesys.h, tm01/task1.c, tm02/task1.c, tm03/task1.c, tm04/task1.c, tm05/task1.c, tm06/task1.c, tm07/task1.c, tm08/task1.c, tm09/task1.c, tm10/task1.c, tm11/task1.c, tm12/task1.c, tm13/task1.c, tm14/task1.c, tm15/task1.c, tm16/task1.c, tm17/task1.c, tm18/task1.c, tm20/task1.c, tm21/task1.c, tm22/task1.c, tm23/task1.c, tm24/task1.c, tm25/task1.c, tm26/task1.c, tm27/task1.c, tm28/task1.c, tm29/task1.c, tmck/task1.c, tmoverhd/testtask.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 3.4 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
14#define TEST_INIT
15#include "system.h"
16
17#define MAXIMUM_DISTRIBUTION 10000
18
19#undef OPERATION_COUNT
20#define OPERATION_COUNT    100000
21
22int Distribution[ MAXIMUM_DISTRIBUTION + 1 ];
23
24rtems_task Task_1(
25  rtems_task_argument argument
26);
27
28void check_read_timer( void );
29
30rtems_task Init(
31  rtems_task_argument argument
32)
33{
34  rtems_id          id;
35  rtems_status_code status;
36
37  /*
38   *  Tell the Timer Driver what we are doing
39   */
40
41  Set_find_average_overhead( 1 );
42
43  Print_Warning();
44
45  puts( "\n\n*** TIME CHECKER ***" );
46
47  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ),
48
49  status = rtems_task_create(
50    1,
51    5,
52    RTEMS_MINIMUM_STACK_SIZE,
53    RTEMS_DEFAULT_MODES,
54    RTEMS_DEFAULT_ATTRIBUTES,
55    &id
56  );
57  directive_failed( status, "rtems_task_create of TA1" );
58
59  status = rtems_task_start( id, Task_1, 0 );
60  directive_failed( status, "rtems_task_start of TA1" );
61
62  status = rtems_task_delete( RTEMS_SELF );
63  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
64}
65
66rtems_task Task_1(
67  rtems_task_argument argument
68)
69{
70  uint32_t   index;
71
72  check_read_timer();
73rtems_test_pause();
74
75  Timer_initialize();
76  end_time = Read_timer();
77
78  put_time(
79    "NULL timer stopped at",
80    end_time,
81    1,
82    0,
83    0
84  );
85
86  Timer_initialize();
87  for ( index = 1 ; index <= 1000 ; index++ )
88    (void) Empty_function();
89  end_time = Read_timer();
90
91  put_time(
92    "LOOP (1000) timer stopped at",
93    end_time,
94    1,
95    0,
96    0
97  );
98
99  Timer_initialize();
100  for ( index = 1 ; index <= 10000 ; index++ )
101    (void) Empty_function();
102  end_time = Read_timer();
103
104  put_time(
105    "LOOP (10000) timer stopped at",
106    end_time,
107    1,
108    0,
109    0
110  );
111
112  Timer_initialize();
113  for ( index = 1 ; index <= 50000 ; index++ )
114    (void) Empty_function();
115  end_time = Read_timer();
116
117  put_time(
118    "LOOP (50000) timer stopped at",
119    end_time,
120    1,
121    0,
122    0
123  );
124
125  Timer_initialize();
126  for ( index = 1 ; index <= 100000 ; index++ )
127    (void) Empty_function();
128  end_time = Read_timer();
129
130  put_time(
131    "LOOP (100000) timer stopped at",
132    end_time,
133    1,
134    0,
135    0
136  );
137
138  puts( "*** END OF TIME CHECKER ***" );
139  rtems_test_exit( 0 );
140}
141
142void check_read_timer()
143{
144  uint32_t   index;
145  uint32_t   time;
146
147  for ( index = 1 ; index <= MAXIMUM_DISTRIBUTION ; index++ )
148    Distribution[ index ] = 0;
149
150  for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) {
151    Timer_initialize();
152    end_time = Read_timer();
153    if ( end_time > MAXIMUM_DISTRIBUTION ) {
154      /*
155       *  Under UNIX a simple process swap takes longer than we
156       *  consider valid for our testing purposes.
157       */
158      printf( "TOO LONG (%d) at index %d!!!\n", end_time, index );
159#if defined(unix)
160      index--; 
161      continue;
162#else
163      rtems_test_exit( 1 );
164#endif
165    }
166    else
167      Distribution[ end_time ]++;
168  }
169
170  printf( "Units may not be in microseconds for this test!!!\n" );
171  time = 0;
172  for ( index = 0 ; index <= MAXIMUM_DISTRIBUTION ; index++ ) {
173    time += (Distribution[ index ] * index);
174    if ( Distribution[ index ] != 0 )
175      printf( "%d %d\n", index, Distribution[ index ] );
176  }
177  printf( "Total time = %d\n", time );
178  printf( "Average time = %d\n", time / OPERATION_COUNT );
179}
Note: See TracBrowser for help on using the repository browser.