source: rtems/testsuites/tmtests/tm01/task1.c @ 5c491aef

4.104.114.84.95
Last change on this file since 5c491aef was 5c491aef, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 20, 1995 at 3:39:19 PM

changes remerged after lost in disk crash -- recovered from snapshot, partially recovered working tree, etc

  • Property mode set to 100644
File size: 4.6 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#define TEST_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    128,
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  rtems_unsigned32  semaphore_obtain_time;
58  rtems_unsigned32  semaphore_release_time;
59  rtems_unsigned32  semaphore_obtain_no_wait_time;
60  rtems_unsigned32  semaphore_obtain_loop_time;
61  rtems_unsigned32  semaphore_release_loop_time;
62  rtems_unsigned32  index;
63  rtems_unsigned32  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  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 = 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    RTEMS_NO_PRIORITY,
114    &smid
115  );
116
117  for ( iterations=OPERATION_COUNT ; iterations ; iterations-- ) {
118
119    Timer_initialize();
120      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
121        (void) Empty_function();
122    end_time = Read_timer();
123
124    semaphore_obtain_loop_time  += end_time;
125    semaphore_release_loop_time += end_time;
126
127    /* rtems_semaphore_obtain (available) */
128
129    Timer_initialize();
130      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
131        (void) rtems_semaphore_obtain(
132          smid,
133          RTEMS_DEFAULT_OPTIONS,
134          RTEMS_NO_TIMEOUT
135        );
136    end_time = Read_timer();
137
138    semaphore_obtain_time += end_time;
139
140    /* rtems_semaphore_release */
141
142    Timer_initialize();
143      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
144        (void) rtems_semaphore_release( smid );
145    end_time = Read_timer();
146
147    semaphore_release_time += end_time;
148
149    /* semaphore obtain (RTEMS_NO_WAIT) */
150    Timer_initialize();
151      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
152        rtems_semaphore_obtain( smid, RTEMS_NO_WAIT, RTEMS_NO_TIMEOUT );
153    semaphore_obtain_no_wait_time += Read_timer();
154
155    Timer_initialize();
156      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
157        rtems_semaphore_release( smid );
158    end_time = Read_timer();
159
160    semaphore_release_time += end_time;
161  }
162
163  put_time(
164    "rtems_semaphore_obtain: available",
165    semaphore_obtain_time,
166    OPERATION_COUNT * OPERATION_COUNT,
167    semaphore_obtain_loop_time,
168    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
169  );
170
171  put_time(
172    "rtems_semaphore_obtain: not available -- NO_WAIT",
173    semaphore_obtain_no_wait_time,
174    OPERATION_COUNT * OPERATION_COUNT,
175    semaphore_obtain_loop_time,
176    CALLING_OVERHEAD_SEMAPHORE_OBTAIN
177  );
178
179  put_time(
180    "rtems_semaphore_release: no waiting tasks",
181    semaphore_release_time,
182    OPERATION_COUNT * OPERATION_COUNT * 2,
183    semaphore_release_loop_time * 2,
184    CALLING_OVERHEAD_SEMAPHORE_RELEASE
185  );
186
187  puts( "*** END OF TEST 1 ***" );
188  exit( 0 );
189}
Note: See TracBrowser for help on using the repository browser.