source: rtems/testsuites/tmtests/tm01/task1.c @ 7f6a24ab

4.104.114.84.95
Last change on this file since 7f6a24ab was 7f6a24ab, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 28, 1995 at 3:30:29 PM

Added unused priority ceiling parameter to rtems_semaphore_create.

Rearranged code to created thread handler routines to initialize,
start, restart, and "close/delete" a thread.

Made internal threads their own object class. This now uses the
thread support routines for starting and initializing a thread.

Insured deleted tasks are freed to the Inactive pool associated with the
correct Information block.

Added an RTEMS API specific data area to the thread control block.

Beginnings of removing the word "rtems" from the core.

  • 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      RTEMS_NO_PRIORITY,
86      &smid
87    );
88  end_time = Read_timer();
89  put_time(
90    "rtems_semaphore_create",
91    end_time,
92    1,
93    0,
94    CALLING_OVERHEAD_SEMAPHORE_CREATE
95  );
96
97  /* Time one invocation of rtems_semaphore_delete */
98
99  Timer_initialize();
100    (void) rtems_semaphore_delete( smid );
101  end_time = Read_timer();
102  put_time(
103    "rtems_semaphore_delete",
104    end_time,
105    1,
106    0,
107    CALLING_OVERHEAD_SEMAPHORE_CREATE
108  );
109
110  status = rtems_semaphore_create(
111    name,
112    OPERATION_COUNT,
113    RTEMS_DEFAULT_ATTRIBUTES,
114    RTEMS_NO_PRIORITY,
115    &smid
116  );
117
118  for ( iterations=OPERATION_COUNT ; iterations ; iterations-- ) {
119
120    Timer_initialize();
121      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
122        (void) Empty_function();
123    end_time = Read_timer();
124
125    semaphore_obtain_loop_time  += end_time;
126    semaphore_release_loop_time += end_time;
127
128    /* rtems_semaphore_obtain (available) */
129
130    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 = Read_timer();
138
139    semaphore_obtain_time += end_time;
140
141    /* rtems_semaphore_release */
142
143    Timer_initialize();
144      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
145        (void) rtems_semaphore_release( smid );
146    end_time = Read_timer();
147
148    semaphore_release_time += end_time;
149
150    /* semaphore obtain (RTEMS_NO_WAIT) */
151    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 += Read_timer();
155
156    Timer_initialize();
157      for ( index = 1 ; index<=OPERATION_COUNT ; index++ )
158        rtems_semaphore_release( smid );
159    end_time = Read_timer();
160
161    semaphore_release_time += end_time;
162  }
163
164  put_time(
165    "rtems_semaphore_obtain",
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 (RTEMS_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",
182    semaphore_release_time,
183    OPERATION_COUNT * OPERATION_COUNT * 2,
184    semaphore_release_loop_time * 2,
185    CALLING_OVERHEAD_SEMAPHORE_RELEASE
186  );
187
188  exit( 0 );
189}
Note: See TracBrowser for help on using the repository browser.