source: rtems/c/src/tests/sptests/sp04/task1.c @ 9b413ea

4.104.114.84.95
Last change on this file since 9b413ea was 9b413ea, checked in by Joel Sherrill <joel.sherrill@…>, on 06/12/98 at 20:55:21

Patch from Eric Norum to avoid printing from context switch user extension.

The array is too long and needs to be shortened.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*  Task_1
2 *
3 *  This test serves as a test task.  It verifies timeslicing activities
4 *  and tswitch extension processing.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989-1998.
12 *  On-Line Applications Research Corporation (OAR).
13 *  Copyright assigned to U.S. Government, 1994.
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.OARcorp.com/rtems/license.html.
18 *
19 *  $Id$
20 */
21
22#include "system.h"
23
24static void
25showTaskSwitches (void)
26{
27  int i;
28  int switches = taskSwitchLogIndex;
29
30  for (i = 0 ; i < switches ; i++) {
31      put_name( Task_name[taskSwitchLog[i].taskIndex], FALSE );
32      print_time( "- ", &taskSwitchLog[i].when, "\n" );
33  }
34}
35
36rtems_task Task_1(
37  rtems_task_argument argument
38)
39{
40  rtems_unsigned32  seconds;
41  rtems_unsigned32  old_seconds;
42  rtems_mode        previous_mode;
43  rtems_time_of_day time;
44  rtems_status_code status;
45  rtems_unsigned32  start_time;
46  rtems_unsigned32  end_time;
47
48  puts( "TA1 - rtems_task_suspend - on Task 2" );
49  status = rtems_task_suspend( Task_id[ 2 ] );
50  directive_failed( status, "rtems_task_suspend of TA2" );
51
52  puts( "TA1 - rtems_task_suspend - on Task 3" );
53  status = rtems_task_suspend( Task_id[ 3 ] );
54  directive_failed( status, "rtems_task_suspend of TA3" );
55
56  status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &start_time );
57  directive_failed( status, "rtems_clock_get" );
58
59  puts( "TA1 - killing time" );
60
61  for ( ; ; ) {
62    status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &end_time );
63    directive_failed( status, "rtems_clock_get" );
64
65    if ( end_time > (start_time + 2) )
66      break;
67  }
68
69  puts( "TA1 - rtems_task_resume - on Task 2" );
70  status = rtems_task_resume( Task_id[ 2 ] );
71  directive_failed( status, "rtems_task_resume of TA2" );
72
73  puts( "TA1 - rtems_task_resume - on Task 3" );
74  status = rtems_task_resume( Task_id[ 3 ] );
75  directive_failed( status, "rtems_task_resume of TA3" );
76
77  while ( FOREVER ) {
78    if ( Run_count[ 1 ] == 3 ) {
79      puts( "TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT" );
80
81      status = rtems_task_mode(
82        RTEMS_NO_PREEMPT,
83        RTEMS_PREEMPT_MASK,
84        &previous_mode
85      );
86      directive_failed( status, "rtems_task_mode" );
87
88      status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
89      directive_failed( status, "rtems_clock_get" );
90
91      old_seconds = time.second;
92
93      for ( seconds = 0 ; seconds < 6 ; ) {
94        status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
95        directive_failed( status, "rtems_clock_get" );
96
97        if ( time.second != old_seconds ) {
98          old_seconds = time.second;
99          seconds++;
100          print_time( "TA1 - ", &time, "\n" );
101        }
102      }
103
104      puts( "TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT" );
105      status = rtems_task_mode(
106        RTEMS_PREEMPT,
107        RTEMS_PREEMPT_MASK,
108        &previous_mode
109      );
110      directive_failed( status, "rtems_task_mode" );
111
112      while ( !testsFinished );
113      showTaskSwitches ();
114      puts( "*** END OF TEST 4 ***" );
115      exit (0);
116    }
117  }
118}
Note: See TracBrowser for help on using the repository browser.