1 | /** |
---|
2 | * @file rtems/score/priority.h |
---|
3 | * |
---|
4 | * This include file contains all thread priority manipulation routines. |
---|
5 | * This Handler provides mechanisms which can be used to |
---|
6 | * initialize and manipulate thread priorities. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2006. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.com/license/LICENSE. |
---|
16 | * |
---|
17 | * $Id$ |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef _RTEMS_SCORE_PRIORITY_H |
---|
21 | #define _RTEMS_SCORE_PRIORITY_H |
---|
22 | |
---|
23 | /** |
---|
24 | * @defgroup ScorePriority Priority Handler |
---|
25 | * |
---|
26 | * This handler encapsulates functionality which is used to manage |
---|
27 | * thread priorities. At the SuperCore level 256 priority levels |
---|
28 | * are supported with lower numbers representing logically more important |
---|
29 | * threads. The priority level 0 is reserved for internal RTEMS use. |
---|
30 | * Typically it is assigned to threads which defer internal RTEMS |
---|
31 | * actions from an interrupt to thread level to improve interrupt response. |
---|
32 | * Priority level 255 is assigned to the IDLE thread and really should not |
---|
33 | * be used by application threads. The default IDLE thread implementation |
---|
34 | * is an infinite "branch to self" loop which never yields to other threads |
---|
35 | * at the same priority. |
---|
36 | */ |
---|
37 | /**@{*/ |
---|
38 | |
---|
39 | /* |
---|
40 | * Processor specific information. |
---|
41 | */ |
---|
42 | #include <rtems/score/cpu.h> |
---|
43 | |
---|
44 | #ifdef __cplusplus |
---|
45 | extern "C" { |
---|
46 | #endif |
---|
47 | |
---|
48 | /** |
---|
49 | * The following type defines the control block used to manage |
---|
50 | * thread priorities. |
---|
51 | * |
---|
52 | * @note Priority 0 is reserved for internal threads only. |
---|
53 | */ |
---|
54 | typedef uint32_t Priority_Control; |
---|
55 | |
---|
56 | /** This defines the highest (most important) thread priority. */ |
---|
57 | #define PRIORITY_MINIMUM 0 |
---|
58 | |
---|
59 | /** This defines the default lowest (least important) thread priority. */ |
---|
60 | #if defined (CPU_PRIORITY_MAXIMUM) |
---|
61 | #define PRIORITY_DEFAULT_MAXIMUM CPU_PRIORITY_MAXIMUM |
---|
62 | #else |
---|
63 | #define PRIORITY_DEFAULT_MAXIMUM 255 |
---|
64 | #endif |
---|
65 | |
---|
66 | /** This defines the lowest (least important) thread priority. */ |
---|
67 | #define PRIORITY_MAXIMUM rtems_maximum_priority |
---|
68 | |
---|
69 | /** |
---|
70 | * The following record defines the information associated with |
---|
71 | * each thread to manage its interaction with the priority bit maps. |
---|
72 | */ |
---|
73 | typedef struct { |
---|
74 | /** This is the address of minor bit map slot. */ |
---|
75 | Priority_Bit_map_control *minor; |
---|
76 | /** This is the priority bit map ready mask. */ |
---|
77 | Priority_Bit_map_control ready_major; |
---|
78 | /** This is the priority bit map ready mask. */ |
---|
79 | Priority_Bit_map_control ready_minor; |
---|
80 | /** This is the priority bit map block mask. */ |
---|
81 | Priority_Bit_map_control block_major; |
---|
82 | /** This is the priority bit map block mask. */ |
---|
83 | Priority_Bit_map_control block_minor; |
---|
84 | } Priority_Information; |
---|
85 | |
---|
86 | /** |
---|
87 | * This variable contains the configured number of priorities |
---|
88 | */ |
---|
89 | extern uint8_t rtems_maximum_priority; |
---|
90 | |
---|
91 | /** |
---|
92 | * Each sixteen bit entry in this array is associated with one of |
---|
93 | * the sixteen entries in the Priority Bit map. |
---|
94 | */ |
---|
95 | SCORE_EXTERN volatile Priority_Bit_map_control _Priority_Major_bit_map; |
---|
96 | |
---|
97 | /** Each bit in the Priority Bitmap indicates whether or not there are |
---|
98 | * threads ready at a particular priority. The mapping of |
---|
99 | * individual priority levels to particular bits is processor |
---|
100 | * dependent as is the value of each bit used to indicate that |
---|
101 | * threads are ready at that priority. |
---|
102 | */ |
---|
103 | SCORE_EXTERN Priority_Bit_map_control |
---|
104 | _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT; |
---|
105 | |
---|
106 | /* |
---|
107 | * The definition of the Priority_Bit_map_control type is CPU dependent. |
---|
108 | * |
---|
109 | */ |
---|
110 | |
---|
111 | #if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) |
---|
112 | /** |
---|
113 | * This method returns the priority bit mask for the specified major |
---|
114 | * or minor bit number. |
---|
115 | * |
---|
116 | * @param[in] _bit_number is the bit number for which we need a mask |
---|
117 | * |
---|
118 | * @return the priority bit mask |
---|
119 | * |
---|
120 | * @note This may simply be a pass through to a CPU dependent implementation. |
---|
121 | */ |
---|
122 | #define _Priority_Mask( _bit_number ) \ |
---|
123 | _CPU_Priority_Mask( _bit_number ) |
---|
124 | #endif |
---|
125 | |
---|
126 | #if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) |
---|
127 | /** |
---|
128 | * This method returns the bit index position for the specified priority. |
---|
129 | * |
---|
130 | * @param[in] _priority is the priority for which we need the index. |
---|
131 | * |
---|
132 | * @return This method returns the array index into the priority bit map. |
---|
133 | * |
---|
134 | * @note This may simply be a pass through to a CPU dependent implementation. |
---|
135 | */ |
---|
136 | #define _Priority_Bits_index( _priority ) \ |
---|
137 | _CPU_Priority_bits_index( _priority ) |
---|
138 | #endif |
---|
139 | |
---|
140 | #ifndef __RTEMS_APPLICATION__ |
---|
141 | #include <rtems/score/priority.inl> |
---|
142 | #endif |
---|
143 | |
---|
144 | #ifdef __cplusplus |
---|
145 | } |
---|
146 | #endif |
---|
147 | |
---|
148 | /**@}*/ |
---|
149 | |
---|
150 | #endif |
---|
151 | /* end of include file */ |
---|