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 | * $Id$ |
---|
20 | */ |
---|
21 | |
---|
22 | #include "system.h" |
---|
23 | #include "clockdrv.h" |
---|
24 | |
---|
25 | rtems_task Task_1( |
---|
26 | rtems_task_argument argument |
---|
27 | ) |
---|
28 | { |
---|
29 | rtems_unsigned32 seconds; |
---|
30 | rtems_unsigned32 old_seconds; |
---|
31 | rtems_mode previous_mode; |
---|
32 | rtems_time_of_day time; |
---|
33 | rtems_status_code status; |
---|
34 | rtems_unsigned32 start; |
---|
35 | rtems_unsigned32 end; |
---|
36 | |
---|
37 | puts( "TA1 - rtems_task_suspend - on Task 2" ); |
---|
38 | status = rtems_task_suspend( Task_id[ 2 ] ); |
---|
39 | directive_failed( status, "rtems_task_suspend of TA2" ); |
---|
40 | |
---|
41 | puts( "TA1 - rtems_task_suspend - on Task 3" ); |
---|
42 | status = rtems_task_suspend( Task_id[ 3 ] ); |
---|
43 | directive_failed( status, "rtems_task_suspend of TA3" ); |
---|
44 | |
---|
45 | status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &start ); |
---|
46 | directive_failed( status, "rtems_clock_get" ); |
---|
47 | |
---|
48 | puts( "TA1 - killing time" ); |
---|
49 | |
---|
50 | for ( ; ; ) { |
---|
51 | status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &end ); |
---|
52 | directive_failed( status, "rtems_clock_get" ); |
---|
53 | |
---|
54 | if ( end > (start + 2) ) |
---|
55 | break; |
---|
56 | } |
---|
57 | |
---|
58 | puts( "TA1 - rtems_task_resume - on Task 2" ); |
---|
59 | status = rtems_task_resume( Task_id[ 2 ] ); |
---|
60 | directive_failed( status, "rtems_task_resume of TA2" ); |
---|
61 | |
---|
62 | puts( "TA1 - rtems_task_resume - on Task 3" ); |
---|
63 | status = rtems_task_resume( Task_id[ 3 ] ); |
---|
64 | directive_failed( status, "rtems_task_resume of TA3" ); |
---|
65 | |
---|
66 | while ( FOREVER ) { |
---|
67 | if ( Run_count[ 1 ] == 3 ) { |
---|
68 | puts( "TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT" ); |
---|
69 | |
---|
70 | status = rtems_task_mode( |
---|
71 | RTEMS_NO_PREEMPT, |
---|
72 | RTEMS_PREEMPT_MASK, |
---|
73 | &previous_mode |
---|
74 | ); |
---|
75 | directive_failed( status, "rtems_task_mode" ); |
---|
76 | |
---|
77 | status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); |
---|
78 | directive_failed( status, "rtems_clock_get" ); |
---|
79 | |
---|
80 | old_seconds = time.second; |
---|
81 | |
---|
82 | for ( seconds = 0 ; seconds < 6 ; ) { |
---|
83 | status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); |
---|
84 | directive_failed( status, "rtems_clock_get" ); |
---|
85 | |
---|
86 | if ( time.second != old_seconds ) { |
---|
87 | old_seconds = time.second; |
---|
88 | seconds++; |
---|
89 | print_time( "TA1 - ", &time, "\n" ); |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | puts( "TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT" ); |
---|
94 | status = rtems_task_mode( |
---|
95 | RTEMS_PREEMPT, |
---|
96 | RTEMS_PREEMPT_MASK, |
---|
97 | &previous_mode |
---|
98 | ); |
---|
99 | directive_failed( status, "rtems_task_mode" ); |
---|
100 | |
---|
101 | while ( FOREVER ); |
---|
102 | } |
---|
103 | } |
---|
104 | } |
---|