source: rtems/c/src/tests/tmtests/tm29/task1.c @ 459f770

4.104.114.84.95
Last change on this file since 459f770 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 4.3 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_name Period_name;
21
22rtems_task Tasks(
23  rtems_task_argument argument
24);
25
26rtems_task Low_task(
27  rtems_task_argument argument
28);
29
30rtems_unsigned32 Task_count;
31
32rtems_task Init(
33  rtems_task_argument argument
34)
35{
36  rtems_id          id;
37  rtems_unsigned32  index;
38  rtems_status_code status;
39
40  puts( "\n\n*** TIME TEST 29 ***" );
41
42  Period_name = rtems_build_name( 'P', 'R', 'D', ' ' );
43
44  Timer_initialize();
45    (void) rtems_rate_monotonic_create( Period_name, &id );
46  end_time = Read_timer();
47
48  put_time(
49    "rtems_rate_monotonic_create",
50    end_time,
51    1,
52    0,
53    CALLING_OVERHEAD_RATE_MONOTONIC_CREATE
54  );
55
56  Timer_initialize();
57    (void) rtems_rate_monotonic_period( id, 10 );
58  end_time = Read_timer();
59
60  put_time(
61    "rtems_rate_monotonic_period (initial)",
62    end_time,
63    1,
64    0,
65    CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD
66  );
67
68  Timer_initialize();
69    (void) rtems_rate_monotonic_period( id, RTEMS_PERIOD_STATUS );
70  end_time = Read_timer();
71
72  put_time(
73    "rtems_rate_monotonic_period (STATUS)",
74    end_time,
75    1,
76    0,
77    CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD
78  );
79
80  Timer_initialize();
81    (void) rtems_rate_monotonic_cancel( id );
82  end_time = Read_timer();
83
84  put_time(
85    "rtems_rate_monotonic_cancel",
86    end_time,
87    1,
88    0,
89    CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL
90  );
91
92  Timer_initialize();
93    (void) rtems_rate_monotonic_delete( id );
94  end_time = Read_timer();
95
96  put_time(
97    "rtems_rate_monotonic_delete (cancelled)",
98    end_time,
99    1,
100    0,
101    CALLING_OVERHEAD_RATE_MONOTONIC_DELETE
102  );
103
104  status = rtems_rate_monotonic_create( Period_name, &id );
105  directive_failed( status, "rtems_rate_monotonic_create" );
106
107  status = rtems_rate_monotonic_period( id, 10 );
108  directive_failed( status, "rtems_rate_monotonic_period" );
109
110  Timer_initialize();
111    rtems_rate_monotonic_delete( id );
112  end_time = Read_timer();
113
114  put_time(
115    "rtems_rate_monotonic_delete (active)",
116    end_time,
117    1,
118    0,
119    CALLING_OVERHEAD_RATE_MONOTONIC_DELETE
120  );
121
122  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
123    status = rtems_task_create(
124      rtems_build_name( 'T', 'E', 'S', 'T' ),
125      128,
126      1024,
127      RTEMS_DEFAULT_MODES,
128      RTEMS_DEFAULT_ATTRIBUTES,
129      &id
130    );
131    directive_failed( status, "rtems_task_create LOOP" );
132
133    status = rtems_task_start( id, Tasks, 0 );
134    directive_failed( status, "rtems_task_start LOOP" );
135  }
136
137  status = rtems_task_create(
138    rtems_build_name( 'L', 'O', 'W', ' ' ),
139    200,
140    2048,
141    RTEMS_DEFAULT_MODES,
142    RTEMS_DEFAULT_ATTRIBUTES,
143    &id
144  );
145  directive_failed( status, "rtems_task_create LOW" );
146
147  status = rtems_task_start( id, Low_task, 0 );
148  directive_failed( status, "rtems_task_start LOW" );
149
150  Task_count = 0;
151
152  status = rtems_task_delete( RTEMS_SELF );
153  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
154}
155
156rtems_task Tasks(
157  rtems_task_argument argument
158)
159{
160  rtems_id          id;
161  rtems_status_code status;
162
163  status = rtems_rate_monotonic_create( 1, &id );
164  directive_failed( status, "rtems_rate_monotonic_create" );
165
166  status = rtems_rate_monotonic_period( id, 100 );
167  directive_failed( status, "rtems_rate_monotonic_period" );
168
169  /*
170   *  Give up the processor to allow all tasks to actually
171   *  create and start their period timer before the benchmark
172   *  timer is initialized.
173   */
174
175  (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
176
177  Task_count++;
178
179  if ( Task_count == 1 )
180    Timer_initialize();
181
182  (void) rtems_rate_monotonic_period( id, 100 );
183}
184
185rtems_task Low_task(
186  rtems_task_argument argument
187)
188{
189  rtems_unsigned32 index;
190
191  end_time = Read_timer();
192
193  Timer_initialize();
194    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
195      (void) Empty_function();
196  overhead = Read_timer();
197
198  put_time(
199    "rtems_rate_monotonic_period (blocking)",
200    end_time,
201    OPERATION_COUNT,
202    overhead,
203    CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD
204  );
205
206  exit( 0 );
207}
Note: See TracBrowser for help on using the repository browser.