source: rtems/c/src/tests/tmtests/tm06/task1.c @ 08311cc3

4.104.114.84.95
Last change on this file since 08311cc3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989-1999.
4 *  On-Line Applications Research Corporation (OAR).
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.OARcorp.com/rtems/license.html.
9 *
10 *  $Id$
11 */
12
13#define TEST_INIT
14#include "system.h"
15
16rtems_id Task_id[ OPERATION_COUNT + 1 ];
17
18rtems_unsigned32 Task_restarted;
19
20rtems_task null_task(
21  rtems_task_argument argument
22);
23
24rtems_task Task_1(
25  rtems_task_argument argument
26);
27
28void test_init( void );
29
30rtems_task Init(
31  rtems_task_argument argument
32)
33{
34  rtems_status_code status;
35
36  Print_Warning();
37
38  puts( "\n\n*** TIME TEST 6 ***" );
39
40  test_init();
41
42  status = rtems_task_delete( RTEMS_SELF );
43  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
44}
45
46void test_init( void )
47{
48  rtems_status_code status;
49  rtems_id id;
50
51  Task_restarted = OPERATION_COUNT;
52
53  status = rtems_task_create(
54    rtems_build_name( 'T', 'I', 'M', 'E' ),
55    128,
56    RTEMS_MINIMUM_STACK_SIZE,
57    RTEMS_DEFAULT_MODES,
58    RTEMS_DEFAULT_ATTRIBUTES,
59    &id
60  );
61  directive_failed( status, "rtems_task_create" );
62
63  status = rtems_task_start( id, Task_1, 0 );
64  directive_failed( status, "rtems_task_start" );
65}
66
67rtems_task Task_1(
68  rtems_task_argument argument
69)
70{
71  rtems_status_code status;
72  rtems_unsigned32  index;
73
74  if ( Task_restarted == OPERATION_COUNT )
75     Timer_initialize();
76
77  Task_restarted--;
78
79  if ( Task_restarted != 0 )
80    (void) rtems_task_restart( RTEMS_SELF, 0 );
81
82  end_time = Read_timer();
83
84  Timer_initialize();
85    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
86      (void) Empty_function();
87  overhead = Read_timer();
88
89  put_time(
90    "rtems_task_restart: calling task",
91    end_time,
92    OPERATION_COUNT,
93    overhead,
94    CALLING_OVERHEAD_TASK_RESTART
95  );
96
97  for ( index=1 ; index <= OPERATION_COUNT ; index++ ) {
98    status = rtems_task_create(
99      rtems_build_name( 'T', 'I', 'M', 'E' ),
100      254,
101      RTEMS_MINIMUM_STACK_SIZE,
102      RTEMS_DEFAULT_MODES,
103      RTEMS_DEFAULT_ATTRIBUTES,
104      &Task_id[ index ]
105    );
106    directive_failed( status, "rtems_task_create loop" );
107
108    status = rtems_task_start( Task_id[ index ], null_task, 0 );
109    directive_failed( status, "rtems_task_start loop" );
110  }
111
112  Timer_initialize();
113    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
114      (void) rtems_task_suspend( Task_id[ index ] );
115  end_time = Read_timer();
116
117  put_time(
118    "rtems_task_suspend: returns to caller",
119    end_time,
120    OPERATION_COUNT,
121    0,
122    CALLING_OVERHEAD_TASK_SUSPEND
123  );
124
125  Timer_initialize();
126    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
127      (void) rtems_task_resume( Task_id[ index ] );
128  end_time = Read_timer();
129
130  put_time(
131    "rtems_task_resume: task readied -- returns to caller",
132    end_time,
133    OPERATION_COUNT,
134    0,
135    CALLING_OVERHEAD_TASK_RESUME
136  );
137
138  Timer_initialize();
139    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
140      (void) rtems_task_delete( Task_id[ index ] );
141  end_time = Read_timer();
142
143  put_time(
144    "rtems_task_delete: ready task",
145    end_time,
146    OPERATION_COUNT,
147    0,
148    CALLING_OVERHEAD_TASK_RESUME
149  );
150
151  puts( "*** END OF TEST 6 ***" );
152  exit( 0 );
153}
154
155rtems_task null_task(
156  rtems_task_argument argument
157)
158{
159  while ( FOREVER )
160    ;
161}
Note: See TracBrowser for help on using the repository browser.