source: rtems/testsuites/sptests/sp04/task1.c @ 3aa4c2e0

4.104.114.84.95
Last change on this file since 3aa4c2e0 was 3aa4c2e0, checked in by Joel Sherrill <joel.sherrill@…>, on 08/02/02 at 00:52:14

2002-08-01 Joel Sherrill <joel@…>

  • Per PR47 add support for buffered test output. This involved adding defines to redirect output to a buffer and dump it when full, at "test pause", and at exit. To avoid problems when redefining exit(), all tests were modified to call rtems_test_exit(). Some tests, notable psxtests, had to be modified to include the standard test macro .h file (pmacros.h or tmacros.h) to enable this support.
  • sp01/task1.c, sp02/task1.c, sp03/task2.c, sp04/task1.c, sp05/task1.c, sp06/task1.c, sp07/taskexit.c, sp08/task1.c, sp09/task1.c, sp11/task1.c, sp12/pritask.c, sp12/task5.c, sp13/task1.c, sp14/task2.c, sp15/task1.c, sp16/task1.c, sp17/task1.c, sp19/fptask.c, sp20/task1.c, sp21/task1.c, sp22/task1.c, sp23/task1.c, sp24/task1.c, sp25/task1.c, sp26/init.c, sp26/task1.c, sp30/task1.c, sp31/task1.c, spsize/init.c, spsize/size.c: Modified.
  • 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-1999.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23static void
24showTaskSwitches (void)
25{
26  int i;
27  int switches = taskSwitchLogIndex;
28
29  for (i = 0 ; i < switches ; i++) {
30      put_name( Task_name[taskSwitchLog[i].taskIndex], FALSE );
31      print_time( "- ", &taskSwitchLog[i].when, "\n" );
32  }
33}
34
35rtems_task Task_1(
36  rtems_task_argument argument
37)
38{
39  rtems_unsigned32  seconds;
40  rtems_unsigned32  old_seconds;
41  rtems_mode        previous_mode;
42  rtems_time_of_day time;
43  rtems_status_code status;
44  rtems_unsigned32  start_time;
45  rtems_unsigned32  end_time;
46
47  puts( "TA1 - rtems_task_suspend - on Task 2" );
48  status = rtems_task_suspend( Task_id[ 2 ] );
49  directive_failed( status, "rtems_task_suspend of TA2" );
50
51  puts( "TA1 - rtems_task_suspend - on Task 3" );
52  status = rtems_task_suspend( Task_id[ 3 ] );
53  directive_failed( status, "rtems_task_suspend of TA3" );
54
55  status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &start_time );
56  directive_failed( status, "rtems_clock_get" );
57
58  puts( "TA1 - killing time" );
59
60  for ( ; ; ) {
61    status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &end_time );
62    directive_failed( status, "rtems_clock_get" );
63
64    if ( end_time > (start_time + 2) )
65      break;
66  }
67
68  puts( "TA1 - rtems_task_resume - on Task 2" );
69  status = rtems_task_resume( Task_id[ 2 ] );
70  directive_failed( status, "rtems_task_resume of TA2" );
71
72  puts( "TA1 - rtems_task_resume - on Task 3" );
73  status = rtems_task_resume( Task_id[ 3 ] );
74  directive_failed( status, "rtems_task_resume of TA3" );
75
76  while ( FOREVER ) {
77    if ( Run_count[ 1 ] >= 3 ) {
78      puts( "TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT" );
79
80      status = rtems_task_mode(
81        RTEMS_NO_PREEMPT,
82        RTEMS_PREEMPT_MASK,
83        &previous_mode
84      );
85      directive_failed( status, "rtems_task_mode" );
86
87      status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
88      directive_failed( status, "rtems_clock_get" );
89
90      old_seconds = time.second;
91
92      for ( seconds = 0 ; seconds < 6 ; ) {
93        status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
94        directive_failed( status, "rtems_clock_get" );
95
96        if ( time.second != old_seconds ) {
97          old_seconds = time.second;
98          seconds++;
99          print_time( "TA1 - ", &time, "\n" );
100        }
101      }
102
103      puts( "TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT" );
104      status = rtems_task_mode(
105        RTEMS_PREEMPT,
106        RTEMS_PREEMPT_MASK,
107        &previous_mode
108      );
109      directive_failed( status, "rtems_task_mode" );
110
111      while ( !testsFinished );
112      showTaskSwitches ();
113      puts( "*** END OF TEST 4 ***" );
114      rtems_test_exit (0);
115    }
116  }
117}
Note: See TracBrowser for help on using the repository browser.