source: rtems/testsuites/tmtests/tm06/task1.c @ 5072b07

4.104.114.84.95
Last change on this file since 5072b07 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: 3.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_id Task_id[ OPERATION_COUNT + 1 ];
21
22rtems_unsigned32 Task_restarted;
23
24rtems_task null_task(
25  rtems_task_argument argument
26);
27
28rtems_task Task_1(
29  rtems_task_argument argument
30);
31
32void test_init( void );
33
34rtems_task Init(
35  rtems_task_argument argument
36)
37{
38  rtems_status_code status;
39
40  puts( "\n\n*** TIME TEST 6 ***" );
41
42  test_init();
43
44  status = rtems_task_delete( RTEMS_SELF );
45  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
46}
47
48void test_init( void )
49{
50  rtems_status_code status;
51  rtems_id id;
52
53  Task_restarted = OPERATION_COUNT;
54
55  status = rtems_task_create(
56    rtems_build_name( 'T', 'I', 'M', 'E' ),
57    128,
58    1024,
59    RTEMS_DEFAULT_MODES,
60    RTEMS_DEFAULT_ATTRIBUTES,
61    &id
62  );
63  directive_failed( status, "rtems_task_create" );
64
65  status = rtems_task_start( id, Task_1, 0 );
66  directive_failed( status, "rtems_task_start" );
67}
68
69rtems_task Task_1(
70  rtems_task_argument argument
71)
72{
73  rtems_status_code status;
74  rtems_unsigned32  index;
75
76  if ( Task_restarted == OPERATION_COUNT )
77     Timer_initialize();
78
79  Task_restarted--;
80
81  if ( Task_restarted != 0 )
82    (void) rtems_task_restart( RTEMS_SELF, 0 );
83
84  end_time = Read_timer();
85
86  Timer_initialize();
87    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
88      (void) Empty_function();
89  overhead = Read_timer();
90
91  put_time(
92    "rtems_task_restart self",
93    end_time,
94    OPERATION_COUNT,
95    overhead,
96    CALLING_OVERHEAD_TASK_RESTART
97  );
98
99  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
100    status = rtems_task_create(
101      rtems_build_name( 'T', 'I', 'M', 'E' ),
102      254,
103      1024,
104      RTEMS_DEFAULT_MODES,
105      RTEMS_DEFAULT_ATTRIBUTES,
106      &Task_id[ index ]
107    );
108    directive_failed( status, "rtems_task_create loop" );
109
110    status = rtems_task_start( Task_id[ index ], null_task, 0 );
111    directive_failed( status, "rtems_task_start loop" );
112  }
113
114  Timer_initialize();
115    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
116      (void) rtems_task_suspend( Task_id[ index ] );
117  end_time = Read_timer();
118
119  put_time(
120    "rtems_task_suspend (no preempt)",
121    end_time,
122    OPERATION_COUNT,
123    0,
124    CALLING_OVERHEAD_TASK_SUSPEND
125  );
126
127  Timer_initialize();
128    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
129      (void) rtems_task_resume( Task_id[ index ] );
130  end_time = Read_timer();
131
132  put_time(
133    "rtems_task_resume (no preempt)",
134    end_time,
135    OPERATION_COUNT,
136    0,
137    CALLING_OVERHEAD_TASK_RESUME
138  );
139
140  Timer_initialize();
141    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
142      (void) rtems_task_delete( Task_id[ index ] );
143  end_time = Read_timer();
144
145  put_time(
146    "rtems_task_delete (others)",
147    end_time,
148    OPERATION_COUNT,
149    0,
150    CALLING_OVERHEAD_TASK_RESUME
151  );
152
153  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.