source: rtems/cpukit/score/inline/rtems/score/priority.inl @ d6154c7

4.104.114.84.95
Last change on this file since d6154c7 was d6154c7, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 29, 2004 at 4:41:13 PM

2004-03-29 Ralf Corsepius <ralf_corsepius@…>

  • score/include/rtems/debug.h, score/include/rtems/score/bitfield.h, score/include/rtems/score/chain.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h, score/include/rtems/score/heap.h, score/include/rtems/score/interr.h, score/include/rtems/score/isr.h, score/include/rtems/score/mpci.h, score/include/rtems/score/mppkt.h, score/include/rtems/score/object.h, score/include/rtems/score/objectmp.h, score/include/rtems/score/priority.h, score/include/rtems/score/stack.h, score/include/rtems/score/states.h, score/include/rtems/score/thread.h, score/include/rtems/score/threadmp.h, score/include/rtems/score/threadq.h, score/include/rtems/score/tod.h, score/include/rtems/score/tqdata.h, score/include/rtems/score/userext.h, score/include/rtems/score/watchdog.h, score/include/rtems/score/wkspace.h, score/inline/rtems/score/address.inl, score/inline/rtems/score/coremsg.inl, score/inline/rtems/score/coresem.inl, score/inline/rtems/score/heap.inl, score/inline/rtems/score/isr.inl, score/inline/rtems/score/object.inl, score/inline/rtems/score/priority.inl, score/inline/rtems/score/stack.inl, score/inline/rtems/score/thread.inl, score/inline/rtems/score/tqdata.inl, score/inline/rtems/score/userext.inl, score/inline/rtems/score/wkspace.inl, score/macros/rtems/score/address.inl, score/macros/rtems/score/heap.inl, score/macros/rtems/score/object.inl, score/macros/rtems/score/priority.inl, score/macros/rtems/score/userext.inl: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*  priority.inl
2 *
3 *  This file contains the static inline implementation of all inlined
4 *  routines in the Priority Handler.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#ifndef __PRIORITY_inl
17#define __PRIORITY_inl
18
19#include <rtems/score/bitfield.h>
20
21/*PAGE
22 *
23 *  _Priority_Handler_initialization
24 *
25 *  DESCRIPTION:
26 *
27 *  This routine performs the initialization necessary for this handler.
28 */
29
30RTEMS_INLINE_ROUTINE void _Priority_Handler_initialization( void )
31{
32  uint32_t   index;
33
34  _Priority_Major_bit_map = 0;
35  for ( index=0 ; index <16 ; index++ )
36     _Priority_Bit_map[ index ] = 0;
37}
38
39/*PAGE
40 *
41 *  _Priority_Is_valid
42 *
43 *  DESCRIPTION:
44 *
45 *  This function returns TRUE if the_priority if valid for a
46 *  user task, and FALSE otherwise.
47 */
48
49RTEMS_INLINE_ROUTINE boolean _Priority_Is_valid (
50  Priority_Control the_priority
51)
52{
53  /*
54   *  Since PRIORITY_MINIMUM is 0 and priorities are stored unsigned,
55   *  then checking for less than 0 is unnecessary.
56   */
57
58  return ( the_priority <= PRIORITY_MAXIMUM );
59}
60
61/*PAGE
62 *
63 *  _Priority_Major
64 *
65 *  DESCRIPTION:
66 *
67 *  This function returns the major portion of the_priority.
68 */
69
70RTEMS_INLINE_ROUTINE uint32_t   _Priority_Major (
71  Priority_Control the_priority
72)
73{
74  return ( the_priority / 16 );
75}
76
77/*PAGE
78 *
79 *  _Priority_Minor
80 *
81 *  DESCRIPTION:
82 *
83 *  This function returns the minor portion of the_priority.
84 */
85
86RTEMS_INLINE_ROUTINE uint32_t   _Priority_Minor (
87  Priority_Control the_priority
88)
89{
90  return ( the_priority % 16 );
91}
92
93#if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE )
94 
95/*PAGE
96 *
97 *  _Priority_Mask
98 *
99 *  DESCRIPTION:
100 *
101 *  This function returns the mask associated with the major or minor
102 *  number passed to it.
103 */
104 
105RTEMS_INLINE_ROUTINE uint32_t   _Priority_Mask (
106  uint32_t   bit_number
107)
108{
109  return (0x8000 >> bit_number);
110}
111 
112 
113/*PAGE
114 *
115 *  _Priority_Bits_index
116 *
117 *  DESCRIPTION:
118 *
119 *  This function translates the bit numbers returned by the bit scan
120 *  of a priority bit field into something suitable for use as
121 *  a major or minor component of a priority.
122 */
123 
124RTEMS_INLINE_ROUTINE uint32_t   _Priority_Bits_index (
125  uint32_t   bit_number
126)
127{
128  return bit_number;
129}
130
131#endif
132
133/*PAGE
134 *
135 *  _Priority_Add_to_bit_map
136 *
137 *  DESCRIPTION:
138 *
139 *  This routine uses the_priority_map to update the priority
140 *  bit maps to indicate that a thread has been readied.
141 */
142
143RTEMS_INLINE_ROUTINE void _Priority_Add_to_bit_map (
144  Priority_Information *the_priority_map
145)
146{
147  *the_priority_map->minor |= the_priority_map->ready_minor;
148  _Priority_Major_bit_map  |= the_priority_map->ready_major;
149}
150
151/*PAGE
152 *
153 *  _Priority_Remove_from_bit_map
154 *
155 *  DESCRIPTION:
156 *
157 *  This routine uses the_priority_map to update the priority
158 *  bit maps to indicate that a thread has been removed from the
159 *  ready state.
160 */
161
162RTEMS_INLINE_ROUTINE void _Priority_Remove_from_bit_map (
163  Priority_Information *the_priority_map
164)
165{
166  *the_priority_map->minor &= the_priority_map->block_minor;
167  if ( *the_priority_map->minor == 0 )
168    _Priority_Major_bit_map &= the_priority_map->block_major;
169}
170
171/*PAGE
172 *
173 *  _Priority_Get_highest
174 *
175 *  DESCRIPTION:
176 *
177 *  This function returns the priority of the highest priority
178 *  ready thread.
179 */
180
181RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_highest( void )
182{
183  Priority_Bit_map_control minor;
184  Priority_Bit_map_control major;
185
186  _Bitfield_Find_first_bit( _Priority_Major_bit_map, major );
187  _Bitfield_Find_first_bit( _Priority_Bit_map[major], minor );
188
189  return (_Priority_Bits_index( major ) << 4) +
190          _Priority_Bits_index( minor );
191}
192
193/*PAGE
194 *
195 *  _Priority_Initialize_information
196 *
197 *  DESCRIPTION:
198 *
199 *  This routine initializes the_priority_map so that it
200 *  contains the information necessary to manage a thread
201 *  at new_priority.
202 */
203
204RTEMS_INLINE_ROUTINE void _Priority_Initialize_information(
205  Priority_Information *the_priority_map,
206  Priority_Control      new_priority
207)
208{
209  Priority_Bit_map_control major;
210  Priority_Bit_map_control minor;
211  Priority_Bit_map_control mask;
212
213  major = _Priority_Major( new_priority );
214  minor = _Priority_Minor( new_priority );
215
216  the_priority_map->minor =
217    &_Priority_Bit_map[ _Priority_Bits_index(major) ];
218
219  mask = _Priority_Mask( major );
220  the_priority_map->ready_major = mask;
221  the_priority_map->block_major = ~mask;
222
223  mask = _Priority_Mask( minor );
224  the_priority_map->ready_minor = mask;
225  the_priority_map->block_minor = ~mask;
226}
227
228/*PAGE
229 *
230 *  _Priority_Is_group_empty
231 *
232 *  DESCRIPTION:
233 *
234 *  This function returns TRUE if the priority GROUP is empty, and
235 *  FALSE otherwise.
236 */
237
238RTEMS_INLINE_ROUTINE boolean _Priority_Is_group_empty (
239  Priority_Control      the_priority
240)
241{
242  return the_priority == 0;
243}
244
245#endif
246/* end of include file */
Note: See TracBrowser for help on using the repository browser.