source: rtems/testsuites/tmtests/tm01/task1.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

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