source: rtems/testsuites/libtests/cpuuse/task1.c @ 1875546

4.104.115
Last change on this file since 1875546 was 1875546, checked in by Joel Sherrill <joel.sherrill@…>, on 08/10/09 at 16:04:57

2009-08-10 Joel Sherrill <joel.sherrill@…>

  • cpuuse/task1.c, termios/init.c: Convert calls to legacy routine rtems_clock_get( RTEMS_CLOCK_GET_xxx, ..) to rtems_clock_get_xxx().
  • Property mode set to 100644
File size: 2.7 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.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22
23rtems_task Task_1(
24  rtems_task_argument argument
25)
26{
27  uint32_t    seconds;
28  uint32_t    old_seconds;
29  rtems_mode        previous_mode;
30  rtems_time_of_day time;
31  rtems_status_code status;
32  uint32_t    start_time;
33  uint32_t    end_time;
34
35  puts( "TA1 - rtems_task_suspend - on Task 2" );
36  status = rtems_task_suspend( Task_id[ 2 ] );
37  directive_failed( status, "rtems_task_suspend of TA2" );
38
39  puts( "TA1 - rtems_task_suspend - on Task 3" );
40  status = rtems_task_suspend( Task_id[ 3 ] );
41  directive_failed( status, "rtems_task_suspend of TA3" );
42
43  status = rtems_clock_get_seconds_since_epoch( &start_time );
44  directive_failed( status, "rtems_clock_get_seconds_since_epoch" );
45
46  puts( "TA1 - killing time" );
47
48  for ( ; ; ) {
49    status = rtems_clock_get_seconds_since_epoch( &end_time );
50    directive_failed( status, "rtems_clock_get_seconds_since_epoch" );
51
52    if ( end_time > (start_time + 2) )
53      break;
54  }
55
56  puts( "TA1 - rtems_task_resume - on Task 2" );
57  status = rtems_task_resume( Task_id[ 2 ] );
58  directive_failed( status, "rtems_task_resume of TA2" );
59
60  puts( "TA1 - rtems_task_resume - on Task 3" );
61  status = rtems_task_resume( Task_id[ 3 ] );
62  directive_failed( status, "rtems_task_resume of TA3" );
63
64  while ( FOREVER ) {
65    if ( Run_count[ 1 ] == 3 ) {
66      puts( "TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT" );
67
68      status = rtems_task_mode(
69        RTEMS_NO_PREEMPT,
70        RTEMS_PREEMPT_MASK,
71        &previous_mode
72      );
73      directive_failed( status, "rtems_task_mode" );
74
75      status = rtems_clock_get_tod( &time );
76      directive_failed( status, "rtems_clock_get_tod" );
77
78      old_seconds = time.second;
79
80      for ( seconds = 0 ; seconds < 6 ; ) {
81        status = rtems_clock_get_tod( &time );
82        directive_failed( status, "rtems_clock_get_tod" );
83
84        if ( time.second != old_seconds ) {
85          old_seconds = time.second;
86          seconds++;
87          print_time( "TA1 - ", &time, "\n" );
88        }
89      }
90
91      puts( "TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT" );
92      status = rtems_task_mode(
93        RTEMS_PREEMPT,
94        RTEMS_PREEMPT_MASK,
95        &previous_mode
96      );
97      directive_failed( status, "rtems_task_mode" );
98
99      while ( FOREVER );
100    }
101  }
102}
Note: See TracBrowser for help on using the repository browser.