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

4.104.114.84.95
Last change on this file since dd687d9 was dd687d9, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2003 at 6:56:05 PM

2003-09-04 Joel Sherrill <joel@…>

  • include/rtems/debug.h, include/rtems/seterr.h, include/rtems/system.h, include/rtems/score/address.h, include/rtems/score/apiext.h, include/rtems/score/apimutex.h, include/rtems/score/bitfield.h, include/rtems/score/chain.h, include/rtems/score/context.h, include/rtems/score/copyrt.h, include/rtems/score/coremsg.h, include/rtems/score/coremutex.h, include/rtems/score/coresem.h, include/rtems/score/heap.h, include/rtems/score/interr.h, include/rtems/score/isr.h, include/rtems/score/mpci.h, include/rtems/score/mppkt.h, include/rtems/score/object.h, include/rtems/score/objectmp.h, include/rtems/score/priority.h, include/rtems/score/stack.h, include/rtems/score/states.h, include/rtems/score/sysstate.h, include/rtems/score/thread.h, include/rtems/score/threadmp.h, include/rtems/score/threadq.h, include/rtems/score/tod.h, include/rtems/score/tqdata.h, include/rtems/score/userext.h, include/rtems/score/watchdog.h, include/rtems/score/wkspace.h, inline/rtems/score/address.inl, inline/rtems/score/chain.inl, inline/rtems/score/coremsg.inl, inline/rtems/score/coremutex.inl, inline/rtems/score/coresem.inl, inline/rtems/score/heap.inl, inline/rtems/score/isr.inl, inline/rtems/score/mppkt.inl, inline/rtems/score/object.inl, inline/rtems/score/objectmp.inl, inline/rtems/score/priority.inl, inline/rtems/score/stack.inl, inline/rtems/score/states.inl, inline/rtems/score/sysstate.inl, inline/rtems/score/thread.inl, inline/rtems/score/threadmp.inl, inline/rtems/score/tod.inl, inline/rtems/score/tqdata.inl, inline/rtems/score/userext.inl, inline/rtems/score/watchdog.inl, inline/rtems/score/wkspace.inl, macros/rtems/score/address.inl, macros/rtems/score/chain.inl, macros/rtems/score/coremsg.inl, macros/rtems/score/coremutex.inl, macros/rtems/score/coresem.inl, macros/rtems/score/heap.inl, macros/rtems/score/isr.inl, macros/rtems/score/mppkt.inl, macros/rtems/score/object.inl, macros/rtems/score/objectmp.inl, macros/rtems/score/priority.inl, macros/rtems/score/stack.inl, macros/rtems/score/states.inl, macros/rtems/score/sysstate.inl, macros/rtems/score/thread.inl, macros/rtems/score/threadmp.inl, macros/rtems/score/tod.inl, macros/rtems/score/tqdata.inl, macros/rtems/score/userext.inl, macros/rtems/score/watchdog.inl, macros/rtems/score/wkspace.inl, src/apiext.c, src/chain.c, src/coremsg.c, src/coremsgbroadcast.c, src/coremsgclose.c, src/coremsgflush.c, src/coremsgflushsupp.c, src/coremsgflushwait.c, src/coremsginsert.c, src/coremsgseize.c, src/coremsgsubmit.c, src/coremutex.c, src/coremutexflush.c, src/coremutexseize.c, src/coremutexsurrender.c, src/coresem.c, src/coresemflush.c, src/coresemseize.c, src/coresemsurrender.c, src/coretod.c, src/coretodset.c, src/coretodtickle.c, src/coretodtoseconds.c, src/coretodvalidate.c, src/heap.c, src/heapallocate.c, src/heapextend.c, src/heapfree.c, src/heapgetinfo.c, src/heapsizeofuserarea.c, src/heapwalk.c, src/interr.c, src/isr.c, src/iterateoverthreads.c, src/mpci.c, src/object.c, src/objectallocate.c, src/objectallocatebyindex.c, src/objectclearname.c, src/objectcomparenameraw.c, src/objectcomparenamestring.c, src/objectcopynameraw.c, src/objectcopynamestring.c, src/objectextendinformation.c, src/objectfree.c, src/objectget.c, src/objectgetbyindex.c, src/objectgetisr.c, src/objectgetnext.c, src/objectgetnoprotection.c, src/objectidtoname.c, src/objectinitializeinformation.c, src/objectmp.c, src/objectnametoid.c, src/objectshrinkinformation.c, src/thread.c, src/threadchangepriority.c, src/threadclearstate.c, src/threadclose.c, src/threadcreateidle.c, src/threaddelayended.c, src/threaddispatch.c, src/threadevaluatemode.c, src/threadget.c, src/threadhandler.c, src/threadidlebody.c, src/threadinitialize.c, src/threadloadenv.c, src/threadmp.c, src/threadq.c, src/threadqdequeue.c, src/threadqdequeuefifo.c, src/threadqdequeuepriority.c, src/threadqenqueue.c, src/threadqenqueuefifo.c, src/threadqenqueuepriority.c, src/threadqextract.c, src/threadqextractfifo.c, src/threadqextractpriority.c, src/threadqextractwithproxy.c, src/threadqfirst.c, src/threadqfirstfifo.c, src/threadqfirstpriority.c, src/threadqflush.c, src/threadqtimeout.c, src/threadready.c, src/threadreset.c, src/threadresettimeslice.c, src/threadrestart.c, src/threadresume.c, src/threadrotatequeue.c, src/threadsetpriority.c, src/threadsetstate.c, src/threadsettransient.c, src/threadstackallocate.c, src/threadstackfree.c, src/threadstart.c, src/threadstartmultitasking.c, src/threadsuspend.c, src/threadtickletimeslice.c, src/threadyieldprocessor.c, src/userext.c, src/watchdog.c, src/watchdogadjust.c, src/watchdoginsert.c, src/watchdogremove.c, src/watchdogtickle.c, src/wkspace.c: URL for license changed.
  • 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  unsigned32 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 unsigned32 _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 unsigned32 _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 unsigned32 _Priority_Mask (
106  unsigned32 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 unsigned32 _Priority_Bits_index (
125  unsigned32 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.