source: rtems/testsuites/tmtests/tm07/task1.c @ 8389628

4.104.114.84.95
Last change on this file since 8389628 was 5c491aef, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 20, 1995 at 3:39:19 PM

changes remerged after lost in disk crash -- recovered from snapshot, partially recovered working tree, etc

  • Property mode set to 100644
File size: 2.5 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#define TEST_INIT
15#include "system.h"
16
17rtems_id Task_id[ OPERATION_COUNT+1 ], task_index;
18
19rtems_task High_task(
20  rtems_task_argument argument
21);
22
23rtems_task Middle_tasks(
24  rtems_task_argument argument
25);
26
27rtems_task Low_task(
28  rtems_task_argument argument
29);
30
31void test_init();
32
33rtems_task Init(
34  rtems_task_argument argument
35)
36{
37  rtems_status_code status;
38
39  Print_Warning();
40
41  puts( "\n\n*** TIME TEST 7 ***" );
42
43  test_init();
44
45  status = rtems_task_delete( RTEMS_SELF );
46  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
47}
48
49void test_init()
50{
51  rtems_status_code   status;
52  rtems_task_priority priority;
53  rtems_task_entry    task_entry;
54  rtems_unsigned32    index;
55
56  priority = 250;
57
58  for( index=0 ; index <= OPERATION_COUNT ; index++ ) {
59    status = rtems_task_create(
60      rtems_build_name( 'T', 'I', 'M', 'E' ),
61      priority,
62      RTEMS_MINIMUM_STACK_SIZE,
63      RTEMS_DEFAULT_MODES,
64      RTEMS_DEFAULT_ATTRIBUTES,
65      &Task_id[index]
66    );
67    directive_failed( status, "rtems_task_create" );
68    priority--;
69
70    if      ( index == 0 )               task_entry = Low_task;
71    else if ( index == OPERATION_COUNT ) task_entry = High_task;
72    else                                 task_entry = Middle_tasks;
73
74    status = rtems_task_start( Task_id[index], task_entry, 0 );
75    directive_failed( status, "rtems_task_start" );
76  }
77}
78
79rtems_task High_task(
80  rtems_task_argument argument
81)
82{
83  if ( argument != 0 ) {
84    end_time = Read_timer();
85
86    put_time(
87      "rtems_task_restart: suspended task -- preempts caller",
88      end_time,
89      OPERATION_COUNT,
90      0,
91      CALLING_OVERHEAD_TASK_RESTART
92    );
93  } else
94    (void) rtems_task_suspend( RTEMS_SELF );
95
96  puts( "*** END OF TEST 7 ***" );
97  exit( 0 );
98}
99
100rtems_task Middle_tasks(
101  rtems_task_argument argument
102)
103{
104  task_index++;
105
106  if ( argument != 0 )
107    (void) rtems_task_restart( Task_id[ task_index ], 0xffffffff );
108  else
109    (void) rtems_task_suspend( RTEMS_SELF );
110}
111
112rtems_task Low_task(
113  rtems_task_argument argument
114)
115{
116  task_index = 1;
117
118  Timer_initialize();
119  (void) rtems_task_restart( Task_id[ task_index ], 0xffffffff );
120}
Note: See TracBrowser for help on using the repository browser.