source: rtems/cpukit/score/include/rtems/score/bitfield.h @ 23bbc43

4.115
Last change on this file since 23bbc43 was a55e305, checked in by Joel Sherrill <joel.sherrill@…>, on 07/29/10 at 17:52:10

2010-07-29 Gedare Bloom <giddyup44@…>

PR 1635/cpukit

  • sapi/src/exinit.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/bitfield.h, score/include/rtems/score/priority.h, score/include/rtems/score/thread.h, score/inline/rtems/score/priority.inl, score/inline/rtems/score/thread.inl, score/src/threadchangepriority.c, score/src/threadclearstate.c, score/src/threadready.c, score/src/threadresume.c, score/src/threadsetpriority.c, score/src/threadsetstate.c, score/src/threadsettransient.c, score/src/threadsuspend.c: Refactoring of priority handling, to isolate the bitmap implementation of priorities in the supercore so that priority management is a little more modular. This change is in anticipation of scheduler implementations that can select how they manage tracking priority levels / finding the highest priority ready task. Note that most of the changes here are simple renaming, to clarify the use of the bitmap-based priority management.
  • score/include/rtems/score/prioritybitmap.h, score/inline/rtems/score/prioritybitmap.inl: New files.
  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 *  @file  rtems/score/bitfield.h
3 *
4 *  This include file contains all bit field manipulation routines.
5 */
6
7/*
8 *  COPYRIGHT (c) 1989-2006.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#ifndef _RTEMS_SCORE_BITFIELD_H
19#define _RTEMS_SCORE_BITFIELD_H
20
21/**
22 *  @defgroup ScoreBitfield Bitfield Handler
23 *
24 *  This handler encapsulates functionality that is used to manipulate the
25 *  priority bitfields used to lookup which priority has the highest
26 *  priority ready to execute thread.
27 */
28/**@{*/
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#if ( CPU_USE_GENERIC_BITFIELD_DATA == TRUE )
35
36/**
37 *  This table is used by the generic bitfield routines to perform
38 *  a highly optimized bit scan without the use of special CPU
39 *  instructions.
40 */
41#ifndef SCORE_INIT
42extern const unsigned char __log2table[256];
43#else
44const unsigned char __log2table[256] = {
45    7, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
46    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
47    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
48    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
49    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
50    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
51    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
52    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
53    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
60    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
61};
62#endif
63
64#endif
65
66/**
67 *  This routine returns the @a _bit_number of the first bit set
68 *  in the specified value.  The correspondence between @a _bit_number
69 *  and actual bit position is processor dependent.  The search for
70 *  the first bit set may run from most to least significant bit
71 *  or vice-versa.
72 *
73 *  @param[in] _value is the value to bit scan.
74 *  @param[in] _bit_number is the position of the first bit set.
75 *
76 *  @note This routine is used when the executing thread is removed
77 *  from the ready state and, as a result, its performance has a
78 *  significant impact on the performance of the executive as a whole.
79 *
80 *  @note This routine must be a macro because if a CPU specific version
81 *  is used it will most likely use inline assembly.
82 */
83#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE )
84#define _Bitfield_Find_first_bit( _value, _bit_number ) \
85        _CPU_Bitfield_Find_first_bit( _value, _bit_number )
86#else
87#define _Bitfield_Find_first_bit( _value, _bit_number ) \
88  { \
89    register uint32_t   __value = (uint32_t) (_value); \
90    register const unsigned char *__p = __log2table; \
91    \
92    if ( __value < 0x100 ) \
93      (_bit_number) = (Priority_bit_map_Control)( __p[ __value ] + 8 );  \
94    else \
95      (_bit_number) = (Priority_bit_map_Control)( __p[ __value >> 8 ] ); \
96  }
97#endif
98
99#ifdef __cplusplus
100}
101#endif
102
103/**@}*/
104
105#endif
106/* end of include file */
Note: See TracBrowser for help on using the repository browser.