1 | /* priority.h |
---|
2 | * |
---|
3 | * This include file contains all thread priority manipulation routines. |
---|
4 | * This Handler provides mechanisms which can be used to |
---|
5 | * initialize and manipulate thread priorities. |
---|
6 | * |
---|
7 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * All rights assigned to U.S. Government, 1994. |
---|
10 | * |
---|
11 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
12 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
13 | * notice must appear in all copies of this file and its derivatives. |
---|
14 | * |
---|
15 | * $Id$ |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef __PRIORITY_h |
---|
19 | #define __PRIORITY_h |
---|
20 | |
---|
21 | #ifdef __cplusplus |
---|
22 | extern "C" { |
---|
23 | #endif |
---|
24 | |
---|
25 | /* |
---|
26 | * The following type defines the control block used to manage |
---|
27 | * thread priorities. |
---|
28 | * |
---|
29 | * NOTE: Priority 0 is reserved for internal threads only. |
---|
30 | */ |
---|
31 | |
---|
32 | typedef unsigned32 Priority_Control; |
---|
33 | |
---|
34 | #define PRIORITY_MINIMUM 0 /* highest thread priority */ |
---|
35 | #define PRIORITY_MAXIMUM 255 /* lowest thread priority */ |
---|
36 | |
---|
37 | /* |
---|
38 | * The following record defines the information associated with |
---|
39 | * each thread to manage its interaction with the priority bit maps. |
---|
40 | */ |
---|
41 | |
---|
42 | typedef struct { |
---|
43 | Priority_Bit_map_control *minor; /* addr of minor bit map slot */ |
---|
44 | Priority_Bit_map_control ready_major; /* priority bit map ready mask */ |
---|
45 | Priority_Bit_map_control ready_minor; /* priority bit map ready mask */ |
---|
46 | Priority_Bit_map_control block_major; /* priority bit map block mask */ |
---|
47 | Priority_Bit_map_control block_minor; /* priority bit map block mask */ |
---|
48 | } Priority_Information; |
---|
49 | |
---|
50 | /* |
---|
51 | * The following data items are the priority bit map. |
---|
52 | * Each of the sixteen bits used in the _Priority_Major_bit_map is |
---|
53 | * associated with one of the sixteen entries in the _Priority_Bit_map. |
---|
54 | * Each bit in the _Priority_Bit_map indicates whether or not there are |
---|
55 | * threads ready at a particular priority. The mapping of |
---|
56 | * individual priority levels to particular bits is processor |
---|
57 | * dependent as is the value of each bit used to indicate that |
---|
58 | * threads are ready at that priority. |
---|
59 | */ |
---|
60 | |
---|
61 | EXTERN volatile Priority_Bit_map_control _Priority_Major_bit_map; |
---|
62 | EXTERN Priority_Bit_map_control _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT; |
---|
63 | |
---|
64 | /* |
---|
65 | * The definition of the Priority_Bit_map_control type is CPU dependent. |
---|
66 | * |
---|
67 | */ |
---|
68 | |
---|
69 | /* |
---|
70 | * _Priority_Handler_initialization |
---|
71 | * |
---|
72 | * DESCRIPTION: |
---|
73 | * |
---|
74 | * This routine performs the initialization necessary for this handler. |
---|
75 | */ |
---|
76 | |
---|
77 | STATIC INLINE void _Priority_Handler_initialization( void ); |
---|
78 | |
---|
79 | /* |
---|
80 | * _Priority_Is_valid |
---|
81 | * |
---|
82 | * DESCRIPTION: |
---|
83 | * |
---|
84 | * This function returns TRUE if the_priority if valid for a |
---|
85 | * user task, and FALSE otherwise. |
---|
86 | */ |
---|
87 | |
---|
88 | STATIC INLINE boolean _Priority_Is_valid ( |
---|
89 | Priority_Control the_priority |
---|
90 | ); |
---|
91 | |
---|
92 | /* |
---|
93 | * _Priority_Major |
---|
94 | * |
---|
95 | * DESCRIPTION: |
---|
96 | * |
---|
97 | * This function returns the major portion of the_priority. |
---|
98 | */ |
---|
99 | |
---|
100 | STATIC INLINE unsigned32 _Priority_Major ( |
---|
101 | Priority_Control the_priority |
---|
102 | ); |
---|
103 | |
---|
104 | /* |
---|
105 | * _Priority_Minor |
---|
106 | * |
---|
107 | * DESCRIPTION: |
---|
108 | * |
---|
109 | * This function returns the minor portion of the_priority. |
---|
110 | */ |
---|
111 | |
---|
112 | STATIC INLINE unsigned32 _Priority_Minor ( |
---|
113 | Priority_Control the_priority |
---|
114 | ); |
---|
115 | |
---|
116 | /* |
---|
117 | * _Priority_Mask |
---|
118 | * |
---|
119 | * DESCRIPTION: |
---|
120 | * |
---|
121 | * This function returns the mask associated with the major or minor |
---|
122 | * number passed to it. |
---|
123 | */ |
---|
124 | |
---|
125 | #if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE ) |
---|
126 | |
---|
127 | STATIC INLINE unsigned32 _Priority_Mask ( |
---|
128 | unsigned32 bit_number |
---|
129 | ); |
---|
130 | |
---|
131 | #else |
---|
132 | |
---|
133 | #define _Priority_Mask( _bit_number ) \ |
---|
134 | _CPU_Priority_Mask( _bit_number ) |
---|
135 | |
---|
136 | #endif |
---|
137 | |
---|
138 | /* |
---|
139 | * _Priority_Bits_index |
---|
140 | * |
---|
141 | * DESCRIPTION: |
---|
142 | * |
---|
143 | * This function translates the bit numbers returned by the bit scan |
---|
144 | * of a priority bit field into something suitable for use as |
---|
145 | * a major or minor component of a priority. |
---|
146 | */ |
---|
147 | |
---|
148 | #if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE ) |
---|
149 | |
---|
150 | STATIC INLINE unsigned32 _Priority_Bits_index ( |
---|
151 | unsigned32 bit_number |
---|
152 | ); |
---|
153 | |
---|
154 | #else |
---|
155 | |
---|
156 | #define _Priority_Bits_index( _priority ) \ |
---|
157 | _CPU_Priority_bits_index( _priority ) |
---|
158 | |
---|
159 | #endif |
---|
160 | |
---|
161 | /* |
---|
162 | * _Priority_Add_to_bit_map |
---|
163 | * |
---|
164 | * DESCRIPTION: |
---|
165 | * |
---|
166 | * This routine uses the_priority_map to update the priority |
---|
167 | * bit maps to indicate that a thread has been readied. |
---|
168 | */ |
---|
169 | |
---|
170 | STATIC INLINE void _Priority_Add_to_bit_map ( |
---|
171 | Priority_Information *the_priority_map |
---|
172 | ); |
---|
173 | |
---|
174 | /* |
---|
175 | * _Priority_Remove_from_bit_map |
---|
176 | * |
---|
177 | * DESCRIPTION: |
---|
178 | * |
---|
179 | * This routine uses the_priority_map to update the priority |
---|
180 | * bit maps to indicate that a thread has been removed from the |
---|
181 | * ready state. |
---|
182 | */ |
---|
183 | |
---|
184 | STATIC INLINE void _Priority_Remove_from_bit_map ( |
---|
185 | Priority_Information *the_priority_map |
---|
186 | ); |
---|
187 | |
---|
188 | /* |
---|
189 | * _Priority_Get_highest |
---|
190 | * |
---|
191 | * DESCRIPTION: |
---|
192 | * |
---|
193 | * This function returns the priority of the highest priority |
---|
194 | * ready thread. |
---|
195 | */ |
---|
196 | |
---|
197 | STATIC INLINE Priority_Control _Priority_Get_highest( void ); |
---|
198 | |
---|
199 | /* |
---|
200 | * _Priority_Initialize_information |
---|
201 | * |
---|
202 | * DESCRIPTION: |
---|
203 | * |
---|
204 | * This routine initializes the_priority_map so that it |
---|
205 | * contains the information necessary to manage a thread |
---|
206 | * at new_priority. |
---|
207 | */ |
---|
208 | |
---|
209 | STATIC INLINE void _Priority_Initialize_information( |
---|
210 | Priority_Information *the_priority_map, |
---|
211 | Priority_Control new_priority |
---|
212 | ); |
---|
213 | |
---|
214 | /* |
---|
215 | * _Priority_Is_group_empty |
---|
216 | * |
---|
217 | * DESCRIPTION: |
---|
218 | * |
---|
219 | * This function returns TRUE if the priority GROUP is empty, and |
---|
220 | * FALSE otherwise. |
---|
221 | */ |
---|
222 | |
---|
223 | STATIC INLINE boolean _Priority_Is_group_empty ( |
---|
224 | Priority_Control the_priority |
---|
225 | ); |
---|
226 | |
---|
227 | #include <rtems/score/priority.inl> |
---|
228 | |
---|
229 | #ifdef __cplusplus |
---|
230 | } |
---|
231 | #endif |
---|
232 | |
---|
233 | #endif |
---|
234 | /* end of include file */ |
---|