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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [sptests/] [sp22/] [task1.c] - Blame information for rev 607

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  Task_1
2
 *
3
 *  This routine serves as a test task.  It verifies the basic task
4
 *  switching capabilities of the executive.
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:36 chris Exp $
19
 */
20
 
21
#include "system.h"
22
 
23
rtems_task Task_1(
24
  rtems_task_argument argument
25
)
26
{
27
  rtems_id          tmid;
28
  rtems_time_of_day time;
29
  rtems_status_code status;
30
 
31
/* Get id */
32
 
33
  puts( "TA1 - rtems_timer_ident - identing timer 1" );
34
  status = rtems_timer_ident( Timer_name[ 1 ], &tmid );
35
  directive_failed( status, "rtems_timer_ident" );
36
  printf( "TA1 - timer 1 has id (0x%x)\n", tmid );
37
 
38
/* after which is allowed to fire */
39
 
40
  Print_time();
41
 
42
  puts( "TA1 - rtems_timer_fire_after - timer 1 in 3 seconds" );
43
  status = rtems_timer_fire_after(
44
    tmid,
45
    3 * TICKS_PER_SECOND,
46
    Delayed_resume,
47
    NULL
48
  );
49
  directive_failed( status, "rtems_timer_fire_after" );
50
 
51
  puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" );
52
  status = rtems_task_suspend( RTEMS_SELF );
53
  directive_failed( status, "rtems_task_suspend" );
54
 
55
  Print_time();
56
 
57
/* after which is reset and allowed to fire */
58
 
59
  puts( "TA1 - rtems_timer_fire_after - timer 1 in 3 seconds" );
60
  status = rtems_timer_fire_after(
61
    tmid,
62
    3 * TICKS_PER_SECOND,
63
    Delayed_resume,
64
    NULL
65
  );
66
  directive_failed( status, "rtems_timer_fire_after" );
67
 
68
  puts( "TA1 - rtems_task_wake_after - 1 second" );
69
  status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
70
  directive_failed( status, "rtems_task_wake_after" );
71
 
72
  Print_time();
73
 
74
  puts( "TA1 - rtems_timer_reset - timer 1" );
75
  status = rtems_timer_reset( tmid );
76
  directive_failed( status, "rtems_timer_reset" );
77
 
78
  puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" );
79
  status = rtems_task_suspend( RTEMS_SELF );
80
  directive_failed( status, "rtems_task_suspend" );
81
 
82
  Print_time();
83
 
84
  rtems_test_pause();
85
 
86
  /*
87
   *  Reset the time since we do not know how long the user waited
88
   *  before pressing <cr> at the pause.  This insures that the
89
   *  actual output matches the screen.
90
   */
91
 
92
  build_time( &time, 12, 31, 1988, 9, 0, 7, 0 );
93
 
94
  status = rtems_clock_set( &time );
95
  directive_failed( status, "rtems_clock_set" );
96
 
97
/* after which is canceled */
98
 
99
  puts( "TA1 - rtems_timer_fire_after - timer 1 in 3 seconds" );
100
  status = rtems_timer_fire_after(
101
    tmid,
102
    3 * TICKS_PER_SECOND,
103
    Delayed_resume,
104
    NULL
105
  );
106
  directive_failed( status, "rtems_timer_fire_after" );
107
 
108
  puts( "TA1 - rtems_timer_cancel - timer 1" );
109
  status = rtems_timer_cancel( tmid );
110
  directive_failed( status, "rtems_timer_cancel" );
111
 
112
/* when which is allowed to fire */
113
 
114
  Print_time();
115
 
116
  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
117
  directive_failed( status, "rtems_clock_get" );
118
 
119
  time.second += 3;
120
 
121
  puts( "TA1 - rtems_timer_fire_when - timer 1 in 3 seconds" );
122
  status = rtems_timer_fire_when( tmid, &time, Delayed_resume, NULL );
123
  directive_failed( status, "rtems_timer_fire_when" );
124
 
125
  puts( "TA1 - rtems_task_suspend( RTEMS_SELF )" );
126
  status = rtems_task_suspend( RTEMS_SELF );
127
  directive_failed( status, "rtems_task_suspend" );
128
 
129
  Print_time();
130
 
131
/* when which is canceled */
132
 
133
  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
134
  directive_failed( status, "rtems_clock_get" );
135
 
136
  time.second += 3;
137
 
138
  puts( "TA1 - rtems_timer_fire_when - timer 1 in 3 seconds" );
139
  status = rtems_timer_fire_when( tmid, &time, Delayed_resume, NULL );
140
  directive_failed( status, "rtems_timer_fire_when" );
141
 
142
  puts( "TA1 - rtems_task_wake_after - 1 second" );
143
  status = rtems_task_wake_after( 1 * TICKS_PER_SECOND );
144
  directive_failed( status, "rtems_task_wake_after" );
145
 
146
  Print_time();
147
 
148
  puts( "TA1 - rtems_timer_cancel - timer 1" );
149
  status = rtems_timer_cancel( tmid );
150
  directive_failed( status, "rtems_timer_cancel" );
151
 
152
/* delete */
153
  puts( "TA1 - rtems_task_wake_after - YIELD (only task at priority)" );
154
  status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
155
  directive_failed( status, "rtems_task_wake_after" );
156
 
157
  puts( "TA1 - timer_deleting - timer 1" );
158
  status = rtems_timer_delete( tmid );
159
  directive_failed( status, "rtems_timer_delete" );
160
 
161
  puts( "*** END OF TEST 22 *** " );
162
  exit( 0 );
163
}

powered by: WebSVN 2.1.0

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