source: rtems/testsuites/sptests/sp22/task1.c @ 94179e0

4.104.114.84.95
Last change on this file since 94179e0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

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