source: rtems/testsuites/tmtests/tm01/task1.c @ af43554

5
Last change on this file since af43554 was af43554, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:11

tests: Remove TEST_INIT

The TEST_EXTERN is a used only by the system.h style tests and they use
CONFIGURE_INIT appropriately.

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 4.7 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#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16
17const char rtems_test_name[] = "TIME TEST";
18
19rtems_task Test_task(
20  rtems_task_argument argument
21);
22
23rtems_task Init(
24  rtems_task_argument argument
25)
26{
27  rtems_status_code status;
28
29  Print_Warning();
30
31  TEST_BEGIN();
32
33  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
34  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
35  Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
36
37  status = rtems_task_create(
38    Task_name[ 1 ],
39    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
40    RTEMS_MINIMUM_STACK_SIZE,
41    RTEMS_DEFAULT_MODES,
42    RTEMS_DEFAULT_ATTRIBUTES,
43    &Task_id[ 1 ]
44  );
45  directive_failed( status, "rtems_task_create of TA1" );
46
47  status = rtems_task_start( Task_id[ 1 ], Test_task, 0 );
48  directive_failed( status, "rtems_task_start of TA1" );
49
50  status = rtems_task_delete( RTEMS_SELF );
51  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
52
53}
54
55rtems_task Test_task(
56  rtems_task_argument argument
57)
58{
59  uint32_t    semaphore_obtain_time;
60  uint32_t    semaphore_release_time;
61  uint32_t    semaphore_obtain_no_wait_time;
62  uint32_t    semaphore_obtain_loop_time;
63  uint32_t    semaphore_release_loop_time;
64  uint32_t    index;
65  uint32_t    iterations;
66  rtems_name        name;
67  rtems_id          smid;
68  rtems_status_code status;
69
70  name = rtems_build_name( 'S', 'M', '1', ' ' );
71
72  semaphore_obtain_time          = 0;
73  semaphore_release_time         = 0;
74  semaphore_obtain_no_wait_time  = 0;
75  semaphore_obtain_loop_time     = 0;
76  semaphore_release_loop_time    = 0;
77
78
79  /* Time one invocation of rtems_semaphore_create */
80
81  benchmark_timer_initialize();
82    (void) rtems_semaphore_create(
83      name,
84      OPERATION_COUNT,
85      RTEMS_DEFAULT_MODES,
86      RTEMS_NO_PRIORITY,
87      &smid
88    );
89  end_time = benchmark_timer_read();
90  put_time(
91    "rtems_semaphore_create: only case",
92    end_time,
93    1,
94    0,
95    CALLING_OVERHEAD_SEMAPHORE_CREATE
96  );
97
98  /* Time one invocation of rtems_semaphore_delete */
99
100  benchmark_timer_initialize();
101    (void) rtems_semaphore_delete( smid );
102  end_time = benchmark_timer_read();
103  put_time(
104    "rtems_semaphore_delete: only case",
105    end_time,
106    1,
107    0,
108    CALLING_OVERHEAD_SEMAPHORE_CREATE
109  );
110
111  status = rtems_semaphore_create(
112    name,
113    OPERATION_COUNT,
114    RTEMS_DEFAULT_ATTRIBUTES,
115    RTEMS_NO_PRIORITY,
116    &smid
117  );
118  directive_failed( status, "rtems_task_create of TA1" );
119
120  for ( iterations=OPERATION_COUNT ; iterations ; iterations-- ) {
121
122    benchmark_timer_initialize();
123      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
124        (void) benchmark_timer_empty_function();
125    end_time = benchmark_timer_read();
126
127    semaphore_obtain_loop_time  += end_time;
128    semaphore_release_loop_time += end_time;
129
130    /* rtems_semaphore_obtain (available) */
131
132    benchmark_timer_initialize();
133      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
134        (void) rtems_semaphore_obtain(
135          smid,
136          RTEMS_DEFAULT_OPTIONS,
137          RTEMS_NO_TIMEOUT
138        );
139    end_time = benchmark_timer_read();
140
141    semaphore_obtain_time += end_time;
142
143    /* rtems_semaphore_release */
144
145    benchmark_timer_initialize();
146      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
147        (void) rtems_semaphore_release( smid );
148    end_time = benchmark_timer_read();
149
150    semaphore_release_time += end_time;
151
152    /* semaphore obtain (RTEMS_NO_WAIT) */
153    benchmark_timer_initialize();
154      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
155        rtems_semaphore_obtain( smid, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT );
156    semaphore_obtain_no_wait_time += benchmark_timer_read();
157
158    benchmark_timer_initialize();
159      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
160        rtems_semaphore_release( smid );
161    end_time = benchmark_timer_read();
162
163    semaphore_release_time += end_time;
164  }
165
166  put_time(
167    "rtems_semaphore_obtain: available",
168    semaphore_obtain_time,
169    OPERATION_COUNT * OPERATION_COUNT,
170    semaphore_obtain_loop_time,
171    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
172  );
173
174  put_time(
175    "rtems_semaphore_obtain: not available NO_WAIT",
176    semaphore_obtain_no_wait_time,
177    OPERATION_COUNT * OPERATION_COUNT,
178    semaphore_obtain_loop_time,
179    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
180  );
181
182  put_time(
183    "rtems_semaphore_release: no waiting tasks",
184    semaphore_release_time,
185    OPERATION_COUNT * OPERATION_COUNT * 2,
186    semaphore_release_loop_time * 2,
187    CALLING_OVERHEAD_SEMAPHORE_RELEASE
188  );
189
190  TEST_END();
191  rtems_test_exit( 0 );
192}
Note: See TracBrowser for help on using the repository browser.