source: rtems/testsuites/tmtests/tmck/task1.c @ dcdb62d

4.104.114.84.95
Last change on this file since dcdb62d was 95a81ab, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:53:55

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: 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  rtems_unsigned32 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  rtems_unsigned32 index;
145  rtems_unsigned32 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.