RTEMS: cpukit/include/rtems/score/prioritybitmapimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
prioritybitmapimpl.h
Go to the documentation of this file.
1
12/*
13 * COPYRIGHT (c) 1989-2010.
14 * On-Line Applications Research Corporation (OAR).
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20
21#ifndef _RTEMS_SCORE_PRIORITYBITMAPIMPL_H
22#define _RTEMS_SCORE_PRIORITYBITMAPIMPL_H
23
24#include <rtems/score/prioritybitmap.h>
25
26#include <string.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
43extern const unsigned char _Bitfield_Leading_zeros[256];
44
58 RTEMS_INLINE_ROUTINE unsigned int _Bitfield_Find_first_bit(
59 unsigned int value
60)
61{
62 unsigned int bit_number;
63
64#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE )
65 _CPU_Bitfield_Find_first_bit( value, bit_number );
66#elif defined(__GNUC__)
67 bit_number = (unsigned int) __builtin_clz( value )
68 - __SIZEOF_INT__ * __CHAR_BIT__ + 16;
69#else
70 if ( value < 0x100 ) {
71 bit_number = _Bitfield_Leading_zeros[ value ] + 8;
72 } else { \
73 bit_number = _Bitfield_Leading_zeros[ value >> 8 ];
74 }
75#endif
76
77 return bit_number;
78}
79
88 RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Mask(
89 unsigned int bit_number
90)
91{
92#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE )
93 return _CPU_Priority_Mask( bit_number );
94#else
95 return (Priority_bit_map_Word) ( 0x8000u >> bit_number );
96#endif
97}
98
107 RTEMS_INLINE_ROUTINE unsigned int _Priority_Bits_index(
108 unsigned int bit_number
109)
110{
111#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE )
112 return _CPU_Priority_bits_index( bit_number );
113#else
114 return bit_number;
115#endif
116}
117
125 RTEMS_INLINE_ROUTINE unsigned int _Priority_Major( unsigned int the_priority )
126{
127 return the_priority / 16;
128}
129
137 RTEMS_INLINE_ROUTINE unsigned int _Priority_Minor( unsigned int the_priority )
138{
139 return the_priority % 16;
140}
141
147 RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize(
148 Priority_bit_map_Control *bit_map
149)
150{
151 memset( bit_map, 0, sizeof( *bit_map ) );
152}
153
162 RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add (
163 Priority_bit_map_Control *bit_map,
164 Priority_bit_map_Information *bit_map_info
165)
166{
167 *bit_map_info->minor |= bit_map_info->ready_minor;
168 bit_map->major_bit_map |= bit_map_info->ready_major;
169}
170
179 RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove (
180 Priority_bit_map_Control *bit_map,
181 Priority_bit_map_Information *bit_map_info
182)
183{
184 *bit_map_info->minor &= bit_map_info->block_minor;
185 if ( *bit_map_info->minor == 0 )
186 bit_map->major_bit_map &= bit_map_info->block_major;
187}
188
196 RTEMS_INLINE_ROUTINE unsigned int _Priority_bit_map_Get_highest(
197 const Priority_bit_map_Control *bit_map
198)
199{
200 unsigned int minor;
201 unsigned int major;
202
203 major = _Bitfield_Find_first_bit( bit_map->major_bit_map );
204 minor = _Bitfield_Find_first_bit( bit_map->bit_map[ major ] );
205
206 return (_Priority_Bits_index( major ) << 4) +
207 _Priority_Bits_index( minor );
208}
209
218 RTEMS_INLINE_ROUTINE bool _Priority_bit_map_Is_empty(
219 const Priority_bit_map_Control *bit_map
220)
221{
222 return bit_map->major_bit_map == 0;
223}
224
234 RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information(
235 Priority_bit_map_Control *bit_map,
236 Priority_bit_map_Information *bit_map_info,
237 unsigned int new_priority
238)
239{
240 unsigned int major;
241 unsigned int minor;
242 Priority_bit_map_Word mask;
243
244 major = _Priority_Major( new_priority );
245 minor = _Priority_Minor( new_priority );
246
247 bit_map_info->minor = &bit_map->bit_map[ _Priority_Bits_index( major ) ];
248
249 mask = _Priority_Mask( major );
250 bit_map_info->ready_major = mask;
251 bit_map_info->block_major = (Priority_bit_map_Word) ~mask;
252
253 mask = _Priority_Mask( minor );
254 bit_map_info->ready_minor = mask;
255 bit_map_info->block_minor = (Priority_bit_map_Word) ~mask;
256}
257
260#ifdef __cplusplus
261}
262#endif
263
264#endif
265/* end of include file */
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Priority_Major
RTEMS_INLINE_ROUTINE unsigned int _Priority_Major(unsigned int the_priority)
Returns the major portion of the_priority.
Definition: prioritybitmapimpl.h:125
_Priority_bit_map_Get_highest
RTEMS_INLINE_ROUTINE unsigned int _Priority_bit_map_Get_highest(const Priority_bit_map_Control *bit_map)
Gets highest portion of Priority queue bit map.
Definition: prioritybitmapimpl.h:196
_Priority_Bits_index
RTEMS_INLINE_ROUTINE unsigned int _Priority_Bits_index(unsigned int bit_number)
Returns the bit index position for the specified major or minor bit number.
Definition: prioritybitmapimpl.h:107
_Priority_bit_map_Is_empty
RTEMS_INLINE_ROUTINE bool _Priority_bit_map_Is_empty(const Priority_bit_map_Control *bit_map)
Checks if the Priority queue bit map is empty.
Definition: prioritybitmapimpl.h:218
_Priority_bit_map_Add
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add(Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info)
Adds Priority queue bit map information.
Definition: prioritybitmapimpl.h:162
_Priority_Minor
RTEMS_INLINE_ROUTINE unsigned int _Priority_Minor(unsigned int the_priority)
Returns the minor portion of the_priority.
Definition: prioritybitmapimpl.h:137
_Priority_bit_map_Initialize_information
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information(Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info, unsigned int new_priority)
Initializes the bit map information.
Definition: prioritybitmapimpl.h:234
_Priority_bit_map_Remove
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove(Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info)
Removes Priority queue bit map information.
Definition: prioritybitmapimpl.h:179
_Bitfield_Find_first_bit
RTEMS_INLINE_ROUTINE unsigned int _Bitfield_Find_first_bit(unsigned int value)
Returns the bit number of the first bit set in the specified value.
Definition: prioritybitmapimpl.h:58
_Priority_Mask
RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Mask(unsigned int bit_number)
Returns the priority bit mask for the specified major or minor bit number.
Definition: prioritybitmapimpl.h:88
_Priority_bit_map_Initialize
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize(Priority_bit_map_Control *bit_map)
Initializes a bit map.
Definition: prioritybitmapimpl.h:147
_Bitfield_Leading_zeros
const unsigned char _Bitfield_Leading_zeros[256]
Definition: log2table.c:24
prioritybitmap.h
Manipulation Routines for the Bitmap Priority Queue Implementation.
Priority_bit_map_Control
Definition: prioritybitmap.h:42
Priority_bit_map_Control::major_bit_map
Priority_bit_map_Word major_bit_map
Each sixteen bit entry in this word is associated with one of the sixteen entries in the bit map.
Definition: prioritybitmap.h:47
Priority_bit_map_Control::bit_map
Priority_bit_map_Word bit_map[16]
Each bit in the bit map indicates whether or not there are threads ready at a particular priority.
Definition: prioritybitmap.h:57
Priority_bit_map_Information
Definition: prioritybitmap.h:64
Priority_bit_map_Information::block_major
Priority_bit_map_Word block_major
Definition: prioritybitmap.h:72
Priority_bit_map_Information::block_minor
Priority_bit_map_Word block_minor
Definition: prioritybitmap.h:74
Priority_bit_map_Information::ready_major
Priority_bit_map_Word ready_major
Definition: prioritybitmap.h:68
Priority_bit_map_Information::ready_minor
Priority_bit_map_Word ready_minor
Definition: prioritybitmap.h:70
Priority_bit_map_Information::minor
Priority_bit_map_Word * minor
Definition: prioritybitmap.h:66