source: rtems/testsuites/tmtests/tm06/task1.c @ 6c0301d

4.115
Last change on this file since 6c0301d 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: 3.4 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
17rtems_id Task_id[ OPERATION_COUNT + 1 ];
18
19uint32_t   Task_restarted;
20
21rtems_task null_task(
22  rtems_task_argument argument
23);
24
25rtems_task Task_1(
26  rtems_task_argument argument
27);
28
29void test_init( void );
30
31rtems_task Init(
32  rtems_task_argument argument
33)
34{
35  rtems_status_code status;
36
37  Print_Warning();
38
39  puts( "\n\n*** TIME TEST 6 ***" );
40
41  test_init();
42
43  status = rtems_task_delete( RTEMS_SELF );
44  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
45}
46
47void test_init( void )
48{
49  rtems_status_code status;
50  rtems_id          id;
51
52  Task_restarted = OPERATION_COUNT;
53
54  status = rtems_task_create(
55    rtems_build_name( 'T', 'I', 'M', 'E' ),
56    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
57    RTEMS_MINIMUM_STACK_SIZE,
58    RTEMS_DEFAULT_MODES,
59    RTEMS_DEFAULT_ATTRIBUTES,
60    &id
61  );
62  directive_failed( status, "rtems_task_create" );
63
64  status = rtems_task_start( id, Task_1, 0 );
65  directive_failed( status, "rtems_task_start" );
66}
67
68rtems_task Task_1(
69  rtems_task_argument argument
70)
71{
72  rtems_status_code status;
73  uint32_t    index;
74
75  if ( Task_restarted == OPERATION_COUNT )
76     benchmark_timer_initialize();
77
78  Task_restarted--;
79
80  if ( Task_restarted != 0 )
81    (void) rtems_task_restart( RTEMS_SELF, 0 );
82
83  end_time = benchmark_timer_read();
84
85  benchmark_timer_initialize();
86    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
87      (void) benchmark_timer_empty_function();
88  overhead = benchmark_timer_read();
89
90  put_time(
91    "rtems_task_restart: calling task",
92    end_time,
93    OPERATION_COUNT,
94    overhead,
95    CALLING_OVERHEAD_TASK_RESTART
96  );
97
98  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
99    status = rtems_task_create(
100      rtems_build_name( 'T', 'I', 'M', 'E' ),
101      RTEMS_MAXIMUM_PRIORITY - 1u,
102      RTEMS_MINIMUM_STACK_SIZE,
103      RTEMS_DEFAULT_MODES,
104      RTEMS_DEFAULT_ATTRIBUTES,
105      &Task_id[ index ]
106    );
107    directive_failed( status, "rtems_task_create loop" );
108
109    status = rtems_task_start( Task_id[ index ], null_task, 0 );
110    directive_failed( status, "rtems_task_start loop" );
111  }
112
113  benchmark_timer_initialize();
114    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
115      (void) rtems_task_suspend( Task_id[ index ] );
116  end_time = benchmark_timer_read();
117
118  put_time(
119    "rtems_task_suspend: returns to caller",
120    end_time,
121    OPERATION_COUNT,
122    0,
123    CALLING_OVERHEAD_TASK_SUSPEND
124  );
125
126  benchmark_timer_initialize();
127    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
128      (void) rtems_task_resume( Task_id[ index ] );
129  end_time = benchmark_timer_read();
130
131  put_time(
132    "rtems_task_resume: task readied returns to caller",
133    end_time,
134    OPERATION_COUNT,
135    0,
136    CALLING_OVERHEAD_TASK_RESUME
137  );
138
139  benchmark_timer_initialize();
140    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
141      (void) rtems_task_delete( Task_id[ index ] );
142  end_time = benchmark_timer_read();
143
144  put_time(
145    "rtems_task_delete: ready task",
146    end_time,
147    OPERATION_COUNT,
148    0,
149    CALLING_OVERHEAD_TASK_RESUME
150  );
151
152  puts( "*** END OF TEST 6 ***" );
153  rtems_test_exit( 0 );
154}
155
156rtems_task null_task(
157  rtems_task_argument argument
158)
159{
160  while ( FOREVER )
161    ;
162}
Note: See TracBrowser for help on using the repository browser.