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

4.11
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

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

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16
17uint32_t   Task_count;
18
19rtems_task Tasks(
20  rtems_task_argument argument
21);
22
23rtems_task High_task(
24  rtems_task_argument argument
25);
26
27rtems_task Init(
28  rtems_task_argument argument
29)
30{
31  rtems_id          id;
32  uint32_t    index;
33  rtems_status_code status;
34
35  Print_Warning();
36
37  puts( "\n\n*** TIME TEST 24 ***" );
38
39  status = rtems_task_create(
40    rtems_build_name( 'H', 'I', 'G', 'H' ),
41    1,
42    RTEMS_MINIMUM_STACK_SIZE,
43    RTEMS_DEFAULT_MODES,
44    RTEMS_DEFAULT_ATTRIBUTES,
45    &id
46  );
47  directive_failed( status, "rtems_task_create HIGH" );
48
49  status = rtems_task_start( id, High_task, 0 );
50  directive_failed( status, "rtems_task_create HIGH" );
51
52  for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) {
53    status = rtems_task_create(
54      rtems_build_name( 'R', 'E', 'S', 'T' ),
55      (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
56      RTEMS_MINIMUM_STACK_SIZE,
57      RTEMS_DEFAULT_MODES,
58      RTEMS_DEFAULT_ATTRIBUTES,
59      &id
60    );
61    directive_failed( status, "rtems_task_create LOOP" );
62
63    status = rtems_task_start( id, Tasks, 0 );
64    directive_failed( status, "rtems_task_start LOOP" );
65  }
66  status = rtems_task_delete( RTEMS_SELF );
67  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
68}
69
70rtems_task High_task(
71  rtems_task_argument argument
72)
73{
74  rtems_status_code status;
75  uint32_t    index;
76
77  benchmark_timer_initialize();
78    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
79      (void) benchmark_timer_empty_function();
80  overhead = benchmark_timer_read();
81
82  benchmark_timer_initialize();
83    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
84      (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
85  end_time = benchmark_timer_read();
86
87  put_time(
88    "rtems_task_wake_after: yield returns to caller",
89    end_time,
90    OPERATION_COUNT,
91    overhead,
92    CALLING_OVERHEAD_TASK_WAKE_AFTER
93  );
94
95  Task_count = 0;
96
97  status = rtems_task_delete( RTEMS_SELF );
98  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
99}
100
101rtems_task Tasks(
102  rtems_task_argument argument
103)
104{
105  Task_count++;
106
107  if ( Task_count == 1 )
108    benchmark_timer_initialize();
109  else if ( Task_count == OPERATION_COUNT ) {
110    end_time = benchmark_timer_read();
111
112    put_time(
113      "rtems_task_wake_after: yields preempts caller",
114      end_time,
115      OPERATION_COUNT,
116      overhead,
117      CALLING_OVERHEAD_TASK_WAKE_AFTER
118    );
119
120  puts( "*** END OF TEST 24 ***" );
121    rtems_test_exit( 0 );
122  }
123  (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
124}
Note: See TracBrowser for help on using the repository browser.