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

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on May 11, 1995 at 5:39:37 PM

Initial revision

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
4 *  On-Line Applications Research Corporation (OAR).
5 *  All rights assigned to U.S. Government, 1994.
6 *
7 *  This material may be reproduced by or for the U.S. Government pursuant
8 *  to the copyright license under the clause at DFARS 252.227-7013.  This
9 *  notice must appear in all copies of this file and its derivatives.
10 *
11 *  $Id$
12 */
13
14#include "system.h"
15#undef EXTERN
16#define EXTERN
17#include "conftbl.h"
18#include "gvar.h"
19
20rtems_task Test_task(
21  rtems_task_argument argument
22);
23
24rtems_task Init(
25  rtems_task_argument argument
26)
27{
28  rtems_status_code status;
29
30  puts( "\n\n*** TIME TEST 1 ***" );
31
32  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
33  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
34  Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
35
36  status = rtems_task_create(
37    Task_name[ 1 ],
38    128,
39    4096,
40    RTEMS_DEFAULT_MODES,
41    RTEMS_DEFAULT_ATTRIBUTES,
42    &Task_id[ 1 ]
43  );
44  directive_failed( status, "rtems_task_create of TA1" );
45
46  status = rtems_task_start( Task_id[ 1 ], Test_task, 0 );
47  directive_failed( status, "rtems_task_start of TA1" );
48
49  status = rtems_task_delete( RTEMS_SELF );
50  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
51
52}
53
54rtems_task Test_task(
55  rtems_task_argument argument
56)
57{
58  rtems_unsigned32  semaphore_obtain_time;
59  rtems_unsigned32  semaphore_release_time;
60  rtems_unsigned32  semaphore_obtain_no_wait_time;
61  rtems_unsigned32  semaphore_obtain_loop_time;
62  rtems_unsigned32  semaphore_release_loop_time;
63  rtems_unsigned32  index;
64  rtems_unsigned32  iterations;
65  rtems_name        name;
66  rtems_id          smid;
67  rtems_status_code status;
68
69  name = rtems_build_name( 'S', 'M', '1', ' ' );
70
71  semaphore_obtain_time          = 0;
72  semaphore_release_time         = 0;
73  semaphore_obtain_no_wait_time  = 0;
74  semaphore_obtain_loop_time     = 0;
75  semaphore_release_loop_time    = 0;
76
77
78  /* Time one invocation of rtems_semaphore_create */
79
80  Timer_initialize();
81    (void) rtems_semaphore_create(
82      name,
83      OPERATION_COUNT,
84      RTEMS_DEFAULT_MODES,
85      &smid
86    );
87  end_time = Read_timer();
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  Timer_initialize();
99    (void) rtems_semaphore_delete( smid );
100  end_time = Read_timer();
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    &smid
114  );
115
116  for ( iterations=OPERATION_COUNT ; iterations ; iterations-- ) {
117
118    Timer_initialize();
119      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
120        (void) Empty_function();
121    end_time = Read_timer();
122
123    semaphore_obtain_loop_time  += end_time;
124    semaphore_release_loop_time += end_time;
125
126    /* rtems_semaphore_obtain (available) */
127
128    Timer_initialize();
129      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
130        (void) rtems_semaphore_obtain(
131          smid,
132          RTEMS_DEFAULT_OPTIONS,
133          RTEMS_NO_TIMEOUT
134        );
135    end_time = Read_timer();
136
137    semaphore_obtain_time += end_time;
138
139    /* rtems_semaphore_release */
140
141    Timer_initialize();
142      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
143        (void) rtems_semaphore_release( smid );
144    end_time = Read_timer();
145
146    semaphore_release_time += end_time;
147
148    /* semaphore obtain (RTEMS_NO_WAIT) */
149    Timer_initialize();
150      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
151        rtems_semaphore_obtain( smid, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT );
152    semaphore_obtain_no_wait_time += Read_timer();
153
154    Timer_initialize();
155      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
156        rtems_semaphore_release( smid );
157    end_time = Read_timer();
158
159    semaphore_release_time += end_time;
160  }
161
162  put_time(
163    "rtems_semaphore_obtain",
164    semaphore_obtain_time,
165    OPERATION_COUNT * OPERATION_COUNT,
166    semaphore_obtain_loop_time,
167    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
168  );
169
170  put_time(
171    "rtems_semaphore_obtain (RTEMS_NO_WAIT)",
172    semaphore_obtain_no_wait_time,
173    OPERATION_COUNT * OPERATION_COUNT,
174    semaphore_obtain_loop_time,
175    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
176  );
177
178  put_time(
179    "rtems_semaphore_release",
180    semaphore_release_time,
181    OPERATION_COUNT * OPERATION_COUNT * 2,
182    semaphore_release_loop_time * 2,
183    CALLING_OVERHEAD_SEMAPHORE_RELEASE
184  );
185
186  exit( 0 );
187}
Note: See TracBrowser for help on using the repository browser.