source: rtems/c/src/tests/libtests/cpuuse/task1.c @ 61a183a9

4.104.114.84.95
Last change on this file since 61a183a9 was 61a183a9, checked in by Joel Sherrill <joel.sherrill@…>, on 04/09/97 at 20:19:35

new test

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[61a183a9]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, 1990, 1991, 1992, 1993, 1994.
12 *  On-Line Applications Research Corporation (OAR).
13 *  All rights assigned to U.S. Government, 1994.
14 *
15 *  This material may be reproduced by or for the U.S. Government pursuant
16 *  to the copyright license under the clause at DFARS 252.227-7013.  This
17 *  notice must appear in all copies of this file and its derivatives.
18 *
19 *  task1.c,v 1.6 1995/12/19 20:18:40 joel Exp
20 */
21
22#include "system.h"
23
24rtems_task Task_1(
25  rtems_task_argument argument
26)
27{
28  rtems_unsigned32  seconds;
29  rtems_unsigned32  old_seconds;
30  rtems_mode        previous_mode;
31  rtems_time_of_day time;
32  rtems_status_code status;
33  rtems_unsigned32  start_time;
34  rtems_unsigned32  end_time;
35
36  puts( "TA1 - rtems_task_suspend - on Task 2" );
37  status = rtems_task_suspend( Task_id[ 2 ] );
38  directive_failed( status, "rtems_task_suspend of TA2" );
39
40  puts( "TA1 - rtems_task_suspend - on Task 3" );
41  status = rtems_task_suspend( Task_id[ 3 ] );
42  directive_failed( status, "rtems_task_suspend of TA3" );
43
44  status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &start_time );
45  directive_failed( status, "rtems_clock_get" );
46
47  puts( "TA1 - killing time" );
48
49  for ( ; ; ) {
50    status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &end_time );
51    directive_failed( status, "rtems_clock_get" );
52
53    if ( end_time > (start_time + 2) )
54      break;
55  }
56
57  puts( "TA1 - rtems_task_resume - on Task 2" );
58  status = rtems_task_resume( Task_id[ 2 ] );
59  directive_failed( status, "rtems_task_resume of TA2" );
60
61  puts( "TA1 - rtems_task_resume - on Task 3" );
62  status = rtems_task_resume( Task_id[ 3 ] );
63  directive_failed( status, "rtems_task_resume of TA3" );
64
65  while ( FOREVER ) {
66    if ( Run_count[ 1 ] == 3 ) {
67      puts( "TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT" );
68
69      status = rtems_task_mode(
70        RTEMS_NO_PREEMPT,
71        RTEMS_PREEMPT_MASK,
72        &previous_mode
73      );
74      directive_failed( status, "rtems_task_mode" );
75
76      status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
77      directive_failed( status, "rtems_clock_get" );
78
79      old_seconds = time.second;
80
81      for ( seconds = 0 ; seconds < 6 ; ) {
82        status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
83        directive_failed( status, "rtems_clock_get" );
84
85        if ( time.second != old_seconds ) {
86          old_seconds = time.second;
87          seconds++;
88          print_time( "TA1 - ", &time, "\n" );
89        }
90      }
91
92      puts( "TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT" );
93      status = rtems_task_mode(
94        RTEMS_PREEMPT,
95        RTEMS_PREEMPT_MASK,
96        &previous_mode
97      );
98      directive_failed( status, "rtems_task_mode" );
99
100      while ( FOREVER );
101    }
102  }
103}
Note: See TracBrowser for help on using the repository browser.