source: rtems/testsuites/tmtests/tm29/task1.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 4.7 KB
RevLine 
[ac7d5ef0]1/*
[9410d011]2 *  COPYRIGHT (c) 1989-2013.
[ac7d5ef0]3 *  On-Line Applications Research Corporation (OAR).
4 *
[98e4ebf5]5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
[c499856]7 *  http://www.rtems.org/license/LICENSE.
[ac7d5ef0]8 */
9
[a4bc4d6e]10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
[d1128e2]14#define CONFIGURE_INIT
[ac7d5ef0]15#include "system.h"
16
17rtems_name Period_name;
18
19rtems_task Tasks(
20  rtems_task_argument argument
21);
22
23rtems_task Low_task(
24  rtems_task_argument argument
25);
26
[0720ff4]27uint32_t   Task_count;
[ac7d5ef0]28
29rtems_task Init(
30  rtems_task_argument argument
31)
32{
33  rtems_id          id;
[0720ff4]34  uint32_t    index;
[ac7d5ef0]35  rtems_status_code status;
36
[3a4ae6c]37  Print_Warning();
38
[ac7d5ef0]39  puts( "\n\n*** TIME TEST 29 ***" );
40
41  Period_name = rtems_build_name( 'P', 'R', 'D', ' ' );
42
[dbf4f17]43  benchmark_timer_initialize();
[ac7d5ef0]44    (void) rtems_rate_monotonic_create( Period_name, &id );
[dbf4f17]45  end_time = benchmark_timer_read();
[ac7d5ef0]46
47  put_time(
[9410d011]48    "rtems_rate_monotonic_create: only case",
[ac7d5ef0]49    end_time,
50    1,
51    0,
52    CALLING_OVERHEAD_RATE_MONOTONIC_CREATE
53  );
54
[dbf4f17]55  benchmark_timer_initialize();
[ac7d5ef0]56    (void) rtems_rate_monotonic_period( id, 10 );
[dbf4f17]57  end_time = benchmark_timer_read();
[ac7d5ef0]58
59  put_time(
[9410d011]60    "rtems_rate_monotonic_period: initiate period returns to caller",
[ac7d5ef0]61    end_time,
62    1,
63    0,
64    CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD
65  );
66
[dbf4f17]67  benchmark_timer_initialize();
[ac7d5ef0]68    (void) rtems_rate_monotonic_period( id, RTEMS_PERIOD_STATUS );
[dbf4f17]69  end_time = benchmark_timer_read();
[ac7d5ef0]70
71  put_time(
[5c491aef]72    "rtems_rate_monotonic_period: obtain status",
[ac7d5ef0]73    end_time,
74    1,
75    0,
76    CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD
77  );
78
[dbf4f17]79  benchmark_timer_initialize();
[ac7d5ef0]80    (void) rtems_rate_monotonic_cancel( id );
[dbf4f17]81  end_time = benchmark_timer_read();
[ac7d5ef0]82
83  put_time(
[9410d011]84    "rtems_rate_monotonic_cancel: only case",
[ac7d5ef0]85    end_time,
86    1,
87    0,
88    CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL
89  );
90
[dbf4f17]91  benchmark_timer_initialize();
[ac7d5ef0]92    (void) rtems_rate_monotonic_delete( id );
[dbf4f17]93  end_time = benchmark_timer_read();
[ac7d5ef0]94
95  put_time(
[5c491aef]96    "rtems_rate_monotonic_delete: inactive",
[ac7d5ef0]97    end_time,
98    1,
99    0,
100    CALLING_OVERHEAD_RATE_MONOTONIC_DELETE
101  );
102
103  status = rtems_rate_monotonic_create( Period_name, &id );
104  directive_failed( status, "rtems_rate_monotonic_create" );
105
106  status = rtems_rate_monotonic_period( id, 10 );
107  directive_failed( status, "rtems_rate_monotonic_period" );
108
[dbf4f17]109  benchmark_timer_initialize();
[ac7d5ef0]110    rtems_rate_monotonic_delete( id );
[dbf4f17]111  end_time = benchmark_timer_read();
[ac7d5ef0]112
113  put_time(
[5c491aef]114    "rtems_rate_monotonic_delete: active",
[ac7d5ef0]115    end_time,
116    1,
117    0,
118    CALLING_OVERHEAD_RATE_MONOTONIC_DELETE
119  );
120
[1055ce20]121#define LOOP_TASK_PRIORITY ((RTEMS_MAXIMUM_PRIORITY / 2u) + 1u)
[ac7d5ef0]122  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
123    status = rtems_task_create(
124      rtems_build_name( 'T', 'E', 'S', 'T' ),
[4389287a]125      LOOP_TASK_PRIORITY,
[3652ad35]126      RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]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
[1055ce20]137#define MIDDLE_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 2u)
[ac7d5ef0]138  status = rtems_task_create(
139    rtems_build_name( 'L', 'O', 'W', ' ' ),
[4389287a]140    MIDDLE_PRIORITY,
[3652ad35]141    RTEMS_MINIMUM_STACK_SIZE,
[ac7d5ef0]142    RTEMS_DEFAULT_MODES,
143    RTEMS_DEFAULT_ATTRIBUTES,
144    &id
145  );
146  directive_failed( status, "rtems_task_create LOW" );
147
148  status = rtems_task_start( id, Low_task, 0 );
149  directive_failed( status, "rtems_task_start LOW" );
150
151  Task_count = 0;
152
153  status = rtems_task_delete( RTEMS_SELF );
154  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
155}
156
157rtems_task Tasks(
158  rtems_task_argument argument
159)
160{
161  rtems_id          id;
162  rtems_status_code status;
163
164  status = rtems_rate_monotonic_create( 1, &id );
165  directive_failed( status, "rtems_rate_monotonic_create" );
166
167  status = rtems_rate_monotonic_period( id, 100 );
168  directive_failed( status, "rtems_rate_monotonic_period" );
169
170  /*
171   *  Give up the processor to allow all tasks to actually
172   *  create and start their period timer before the benchmark
173   *  timer is initialized.
174   */
175
176  (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
177
178  Task_count++;
179
180  if ( Task_count == 1 )
[dbf4f17]181    benchmark_timer_initialize();
[ac7d5ef0]182
183  (void) rtems_rate_monotonic_period( id, 100 );
184}
185
186rtems_task Low_task(
187  rtems_task_argument argument
188)
189{
[0720ff4]190  uint32_t   index;
[ac7d5ef0]191
[dbf4f17]192  end_time = benchmark_timer_read();
[ac7d5ef0]193
[dbf4f17]194  benchmark_timer_initialize();
[ac7d5ef0]195    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
[dbf4f17]196      (void) benchmark_timer_empty_function();
197  overhead = benchmark_timer_read();
[ac7d5ef0]198
199  put_time(
[9410d011]200    "rtems_rate_monotonic_period: conclude periods caller blocks",
[ac7d5ef0]201    end_time,
202    OPERATION_COUNT,
203    overhead,
204    CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD
205  );
206
[3a4ae6c]207  puts( "*** END OF TEST 29 ***" );
[b454bc9]208  rtems_test_exit( 0 );
[ac7d5ef0]209}
Note: See TracBrowser for help on using the repository browser.