OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [libtests/] [cpuuse/] [task1.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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: task1.c,v 1.2 2001-09-27 12:02:11 chris Exp $
19
 */
20
 
21
#include "system.h"
22
 
23
rtems_task Task_1(
24
  rtems_task_argument argument
25
)
26
{
27
  rtems_unsigned32  seconds;
28
  rtems_unsigned32  old_seconds;
29
  rtems_mode        previous_mode;
30
  rtems_time_of_day time;
31
  rtems_status_code status;
32
  rtems_unsigned32  start_time;
33
  rtems_unsigned32  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( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &start_time );
44
  directive_failed( status, "rtems_clock_get" );
45
 
46
  puts( "TA1 - killing time" );
47
 
48
  for ( ; ; ) {
49
    status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &end_time );
50
    directive_failed( status, "rtems_clock_get" );
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( RTEMS_CLOCK_GET_TOD, &time );
76
      directive_failed( status, "rtems_clock_get" );
77
 
78
      old_seconds = time.second;
79
 
80
      for ( seconds = 0 ; seconds < 6 ; ) {
81
        status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
82
        directive_failed( status, "rtems_clock_get" );
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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.