1 | /* Priority_test_driver |
---|
2 | * |
---|
3 | * This routine is the initialization task for this test program. |
---|
4 | * It is a user initialization task and has the responsibility for creating |
---|
5 | * and starting the tasks that make up the test. If the time of day |
---|
6 | * clock is required for the test, it should also be set to a known |
---|
7 | * value by this function. |
---|
8 | * |
---|
9 | * Input parameters: |
---|
10 | * priority_base - priority_base switch |
---|
11 | * |
---|
12 | * Output parameters: NONE |
---|
13 | * |
---|
14 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
15 | * On-Line Applications Research Corporation (OAR). |
---|
16 | * All rights assigned to U.S. Government, 1994. |
---|
17 | * |
---|
18 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
19 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
20 | * notice must appear in all copies of this file and its derivatives. |
---|
21 | * |
---|
22 | * $Id$ |
---|
23 | */ |
---|
24 | |
---|
25 | #include "system.h" |
---|
26 | |
---|
27 | void Priority_test_driver( |
---|
28 | rtems_unsigned32 priority_base |
---|
29 | ) |
---|
30 | { |
---|
31 | rtems_task_priority previous_priority; |
---|
32 | rtems_unsigned32 index; |
---|
33 | rtems_status_code status; |
---|
34 | |
---|
35 | for ( index = 1 ; index <= 5 ; index++ ) { |
---|
36 | switch ( index ) { |
---|
37 | case 1: |
---|
38 | case 2: |
---|
39 | case 3: |
---|
40 | Task_priority[ index ] = priority_base + index; |
---|
41 | break; |
---|
42 | default: |
---|
43 | Task_priority[ index ] = priority_base + 3; |
---|
44 | break; |
---|
45 | } |
---|
46 | |
---|
47 | status = rtems_task_create( |
---|
48 | Priority_task_name[ index ], |
---|
49 | Task_priority[ index ], |
---|
50 | 2048, |
---|
51 | RTEMS_DEFAULT_MODES, |
---|
52 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
53 | &Priority_task_id[ index ] |
---|
54 | ); |
---|
55 | directive_failed( status, "rtems_task_create loop" ); |
---|
56 | |
---|
57 | } |
---|
58 | |
---|
59 | if ( priority_base == 0 ) { |
---|
60 | for ( index = 1 ; index <= 5 ; index++ ) { |
---|
61 | status = rtems_task_start( |
---|
62 | Priority_task_id[ index ], |
---|
63 | Priority_task, |
---|
64 | index |
---|
65 | ); |
---|
66 | directive_failed( status, "rtems_task_start loop" ); |
---|
67 | } |
---|
68 | } else { |
---|
69 | for ( index = 5 ; index >= 1 ; index-- ) { |
---|
70 | status = rtems_task_start( |
---|
71 | Priority_task_id[ index ], |
---|
72 | Priority_task, |
---|
73 | index |
---|
74 | ); |
---|
75 | directive_failed( status, "rtems_task_start loop" ); |
---|
76 | |
---|
77 | status = rtems_task_wake_after( TICKS_PER_SECOND ); |
---|
78 | directive_failed( status, "rtems_task_wake_after loop" ); |
---|
79 | |
---|
80 | if ( priority_base == 64 ) { |
---|
81 | if ( index == 4 ) { |
---|
82 | status = rtems_task_set_priority( |
---|
83 | Priority_task_id[ 5 ], |
---|
84 | priority_base + 4, |
---|
85 | &previous_priority |
---|
86 | ); |
---|
87 | printf( "PDRV - change priority of PRI5 from %d to %d\n", |
---|
88 | previous_priority, |
---|
89 | priority_base + 4 |
---|
90 | ); |
---|
91 | directive_failed( status, "PDRV rtems_task_set_priority" ); |
---|
92 | } |
---|
93 | status = rtems_task_set_priority( |
---|
94 | Priority_task_id[ 5 ], |
---|
95 | RTEMS_CURRENT_PRIORITY, |
---|
96 | &previous_priority |
---|
97 | ); |
---|
98 | directive_failed( status, "PDRV rtems_task_set_priority CURRENT" ); |
---|
99 | printf( "PDRV - priority of PRI5 is %d\n", previous_priority ); |
---|
100 | } |
---|
101 | } |
---|
102 | } |
---|
103 | |
---|
104 | status = rtems_task_wake_after( TICKS_PER_SECOND ); |
---|
105 | directive_failed( status, "rtems_task_wake_after after loop" ); |
---|
106 | |
---|
107 | if ( priority_base == 0 ) { |
---|
108 | for ( index = 1 ; index <= 5 ; index++ ) { |
---|
109 | status = rtems_semaphore_release( Semaphore_id[ 2 ] ); |
---|
110 | directive_failed( status, "rtems_semaphore_release loop" ); |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | if ( priority_base == 64 ) { |
---|
115 | puts( "PDRV - rtems_task_resume - PRI5" ); |
---|
116 | status = rtems_task_resume( Priority_task_id[ 5 ] ); |
---|
117 | directive_failed( status, "rtems_task_resume" ); |
---|
118 | |
---|
119 | status = rtems_task_wake_after( 1 * TICKS_PER_SECOND ); |
---|
120 | directive_failed( status, "rtems_task_wake_after so PRI5 can run" ); |
---|
121 | |
---|
122 | status = rtems_task_delete( Priority_task_id[ 5 ] ); |
---|
123 | directive_failed( status, "rtems_task_delete of PRI5" ); |
---|
124 | } |
---|
125 | else { |
---|
126 | for ( index = 1 ; index <= 5 ; index++ ) { |
---|
127 | status = rtems_task_delete( Priority_task_id[ index ] ); |
---|
128 | directive_failed( status, "rtems_task_delete loop" ); |
---|
129 | } |
---|
130 | } |
---|
131 | } |
---|