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 RTEMS 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 __RTEMS_PRIORITY_h |
---|
19 | #define __RTEMS_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 rtems_task_priority; |
---|
33 | |
---|
34 | #define RTEMS_MINIMUM_PRIORITY 1 /* highest thread priority */ |
---|
35 | #define RTEMS_MAXIMUM_PRIORITY 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 following constants are useful when manipulating priority. |
---|
66 | */ |
---|
67 | |
---|
68 | #define RTEMS_CURRENT_PRIORITY 0 /* obtain current priority */ |
---|
69 | |
---|
70 | /* |
---|
71 | * The definition of the Priority_Bit_map_control type is CPU dependent. |
---|
72 | * |
---|
73 | */ |
---|
74 | |
---|
75 | /* |
---|
76 | * _Priority_Handler_initialization |
---|
77 | * |
---|
78 | * DESCRIPTION: |
---|
79 | * |
---|
80 | * This routine performs the initialization necessary for this handler. |
---|
81 | */ |
---|
82 | |
---|
83 | STATIC INLINE void _Priority_Handler_initialization( void ); |
---|
84 | |
---|
85 | /* |
---|
86 | * _Priority_Is_valid |
---|
87 | * |
---|
88 | * DESCRIPTION: |
---|
89 | * |
---|
90 | * This function returns TRUE if the_priority if valid for a |
---|
91 | * user task, and FALSE otherwise. |
---|
92 | */ |
---|
93 | |
---|
94 | STATIC INLINE boolean _Priority_Is_valid ( |
---|
95 | rtems_task_priority the_priority |
---|
96 | ); |
---|
97 | |
---|
98 | /* |
---|
99 | * _Priority_Major |
---|
100 | * |
---|
101 | * DESCRIPTION: |
---|
102 | * |
---|
103 | * This function returns the major portion of the_priority. |
---|
104 | */ |
---|
105 | |
---|
106 | STATIC INLINE unsigned32 _Priority_Major ( |
---|
107 | rtems_task_priority the_priority |
---|
108 | ); |
---|
109 | |
---|
110 | /* |
---|
111 | * _Priority_Minor |
---|
112 | * |
---|
113 | * DESCRIPTION: |
---|
114 | * |
---|
115 | * This function returns the minor portion of the_priority. |
---|
116 | */ |
---|
117 | |
---|
118 | STATIC INLINE unsigned32 _Priority_Minor ( |
---|
119 | rtems_task_priority the_priority |
---|
120 | ); |
---|
121 | |
---|
122 | /* |
---|
123 | * _Priority_Add_to_bit_map |
---|
124 | * |
---|
125 | * DESCRIPTION: |
---|
126 | * |
---|
127 | * This routine uses the_priority_map to update the priority |
---|
128 | * bit maps to indicate that a thread has been readied. |
---|
129 | */ |
---|
130 | |
---|
131 | STATIC INLINE void _Priority_Add_to_bit_map ( |
---|
132 | Priority_Information *the_priority_map |
---|
133 | ); |
---|
134 | |
---|
135 | /* |
---|
136 | * _Priority_Remove_from_bit_map |
---|
137 | * |
---|
138 | * DESCRIPTION: |
---|
139 | * |
---|
140 | * This routine uses the_priority_map to update the priority |
---|
141 | * bit maps to indicate that a thread has been removed from the |
---|
142 | * ready state. |
---|
143 | */ |
---|
144 | |
---|
145 | STATIC INLINE void _Priority_Remove_from_bit_map ( |
---|
146 | Priority_Information *the_priority_map |
---|
147 | ); |
---|
148 | |
---|
149 | /* |
---|
150 | * _Priority_Get_highest |
---|
151 | * |
---|
152 | * DESCRIPTION: |
---|
153 | * |
---|
154 | * This function returns the priority of the highest priority |
---|
155 | * ready thread. |
---|
156 | */ |
---|
157 | |
---|
158 | STATIC INLINE rtems_task_priority _Priority_Get_highest( void ); |
---|
159 | |
---|
160 | /* |
---|
161 | * _Priority_Initialize_information |
---|
162 | * |
---|
163 | * DESCRIPTION: |
---|
164 | * |
---|
165 | * This routine initializes the_priority_map so that it |
---|
166 | * contains the information necessary to manage a thread |
---|
167 | * at new_priority. |
---|
168 | */ |
---|
169 | |
---|
170 | STATIC INLINE void _Priority_Initialize_information( |
---|
171 | Priority_Information *the_priority_map, |
---|
172 | rtems_task_priority new_priority |
---|
173 | ); |
---|
174 | |
---|
175 | /* |
---|
176 | * _Priority_Is_group_empty |
---|
177 | * |
---|
178 | * DESCRIPTION: |
---|
179 | * |
---|
180 | * This function returns TRUE if the priority GROUP is empty, and |
---|
181 | * FALSE otherwise. |
---|
182 | */ |
---|
183 | |
---|
184 | STATIC INLINE boolean _Priority_Is_group_empty ( |
---|
185 | rtems_task_priority the_priority |
---|
186 | ); |
---|
187 | |
---|
188 | #include <rtems/priority.inl> |
---|
189 | |
---|
190 | #ifdef __cplusplus |
---|
191 | } |
---|
192 | #endif |
---|
193 | |
---|
194 | #endif |
---|
195 | /* end of include file */ |
---|