source: rtems/testsuites/tmtests/tm06/task1.c @ 96e4b22

5
Last change on this file since 96e4b22 was 96e4b22, checked in by Chris Johns <chrisj@…>, on 03/06/19 at 09:39:29

testsuite: Make the OPERATION_COUNT a test configuration parameter.

  • Add a small memory test config file.
  • Update the small memory PowerPC BSPs to use the new test config.
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#if !defined(OPERATION_COUNT)
11#define OPERATION_COUNT 100
12#endif
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#define CONFIGURE_INIT
19#include "system.h"
20
21const char rtems_test_name[] = "TIME TEST 6";
22
23rtems_id Task_id[ OPERATION_COUNT + 1 ];
24
25uint32_t   Task_restarted;
26
27rtems_task null_task(
28  rtems_task_argument argument
29);
30
31rtems_task Task_1(
32  rtems_task_argument argument
33);
34
35void test_init( void );
36
37rtems_task Init(
38  rtems_task_argument argument
39)
40{
41  Print_Warning();
42
43  TEST_BEGIN();
44
45  test_init();
46
47  rtems_task_exit();
48}
49
50void test_init( void )
51{
52  rtems_status_code status;
53  rtems_id          id;
54
55  Task_restarted = OPERATION_COUNT;
56
57  status = rtems_task_create(
58    rtems_build_name( 'T', 'I', 'M', 'E' ),
59    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
60    RTEMS_MINIMUM_STACK_SIZE,
61    RTEMS_DEFAULT_MODES,
62    RTEMS_DEFAULT_ATTRIBUTES,
63    &id
64  );
65  directive_failed( status, "rtems_task_create" );
66
67  status = rtems_task_start( id, Task_1, 0 );
68  directive_failed( status, "rtems_task_start" );
69}
70
71rtems_task Task_1(
72  rtems_task_argument argument
73)
74{
75  rtems_status_code status;
76  uint32_t    index;
77
78  if ( Task_restarted == OPERATION_COUNT )
79     benchmark_timer_initialize();
80
81  Task_restarted--;
82
83  if ( Task_restarted != 0 )
84    (void) rtems_task_restart( RTEMS_SELF, 0 );
85
86  end_time = benchmark_timer_read();
87
88  benchmark_timer_initialize();
89    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
90      (void) benchmark_timer_empty_function();
91  overhead = benchmark_timer_read();
92
93  put_time(
94    "rtems_task_restart: calling task",
95    end_time,
96    OPERATION_COUNT,
97    overhead,
98    0
99  );
100
101  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
102    status = rtems_task_create(
103      rtems_build_name( 'T', 'I', 'M', 'E' ),
104      RTEMS_MAXIMUM_PRIORITY - 1u,
105      RTEMS_MINIMUM_STACK_SIZE,
106      RTEMS_DEFAULT_MODES,
107      RTEMS_DEFAULT_ATTRIBUTES,
108      &Task_id[ index ]
109    );
110    directive_failed( status, "rtems_task_create loop" );
111
112    status = rtems_task_start( Task_id[ index ], null_task, 0 );
113    directive_failed( status, "rtems_task_start loop" );
114  }
115
116  benchmark_timer_initialize();
117    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
118      (void) rtems_task_suspend( Task_id[ index ] );
119  end_time = benchmark_timer_read();
120
121  put_time(
122    "rtems_task_suspend: returns to caller",
123    end_time,
124    OPERATION_COUNT,
125    0,
126    0
127  );
128
129  benchmark_timer_initialize();
130    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
131      (void) rtems_task_resume( Task_id[ index ] );
132  end_time = benchmark_timer_read();
133
134  put_time(
135    "rtems_task_resume: task readied returns to caller",
136    end_time,
137    OPERATION_COUNT,
138    0,
139    0
140  );
141
142  benchmark_timer_initialize();
143    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
144      (void) rtems_task_delete( Task_id[ index ] );
145  end_time = benchmark_timer_read();
146
147  put_time(
148    "rtems_task_delete: ready task",
149    end_time,
150    OPERATION_COUNT,
151    0,
152    0
153  );
154
155  TEST_END();
156  rtems_test_exit( 0 );
157}
158
159rtems_task null_task(
160  rtems_task_argument argument
161)
162{
163  while ( FOREVER )
164    ;
165}
Note: See TracBrowser for help on using the repository browser.