Ignore:
Timestamp:
Jul 29, 2010, 5:52:10 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
23bbc43
Parents:
a44edd15
Message:

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/inline/rtems/score/priority.inl

    ra44edd15 ra55e305  
    2929 */
    3030
    31 #include <rtems/score/bitfield.h>
    32 
    33 /**
    34  *  This routine performs the initialization necessary for this handler.
    35  */
    36 
    37 RTEMS_INLINE_ROUTINE void _Priority_Handler_initialization( void )
    38 {
    39   int index;
    40 
    41   _Priority_Major_bit_map = 0;
    42   for ( index=0 ; index <16 ; index++ )
    43      _Priority_Bit_map[ index ] = 0;
    44 }
    45 
    4631/**
    4732 *  This function returns true if the_priority if valid for a
     
    6146}
    6247
    63 /**
    64  *  This function returns the major portion of the_priority.
    65  */
    6648
    67 RTEMS_INLINE_ROUTINE Priority_Bit_map_control   _Priority_Major (
    68   Priority_Control the_priority
    69 )
    70 {
    71   return (Priority_Bit_map_control)( the_priority / 16 );
    72 }
    73 
    74 /**
    75  *  This function returns the minor portion of the_priority.
    76  */
    77 
    78 RTEMS_INLINE_ROUTINE Priority_Bit_map_control   _Priority_Minor (
    79   Priority_Control the_priority
    80 )
    81 {
    82   return (Priority_Bit_map_control)( the_priority % 16 );
    83 }
    84 
    85 #if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE )
    86  
    87 /**
    88  *  This function returns the mask associated with the major or minor
    89  *  number passed to it.
    90  */
    91  
    92 RTEMS_INLINE_ROUTINE Priority_Bit_map_control   _Priority_Mask (
    93   uint32_t   bit_number
    94 )
    95 {
    96   return (Priority_Bit_map_control)(0x8000u >> bit_number);
    97 }
    98  
    99 /**
    100  *  This function returns the mask bit inverted.
    101  */
    102  
    103 RTEMS_INLINE_ROUTINE Priority_Bit_map_control   _Priority_Mask_invert (
    104   uint32_t   mask
    105 )
    106 {
    107   return (Priority_Bit_map_control)(~mask);
    108 }
    109 
    110  
    111 /**
    112  *  This function translates the bit numbers returned by the bit scan
    113  *  of a priority bit field into something suitable for use as
    114  *  a major or minor component of a priority.
    115  */
    116  
    117 RTEMS_INLINE_ROUTINE uint32_t   _Priority_Bits_index (
    118   uint32_t   bit_number
    119 )
    120 {
    121   return bit_number;
    122 }
    123 
    124 #endif
    125 
    126 /**
    127  *  This routine uses the_priority_map to update the priority
    128  *  bit maps to indicate that a thread has been readied.
    129  */
    130 
    131 RTEMS_INLINE_ROUTINE void _Priority_Add_to_bit_map (
    132   Priority_Information *the_priority_map
    133 )
    134 {
    135   *the_priority_map->minor |= the_priority_map->ready_minor;
    136   _Priority_Major_bit_map  |= the_priority_map->ready_major;
    137 }
    138 
    139 /**
    140  *  This routine uses the_priority_map to update the priority
    141  *  bit maps to indicate that a thread has been removed from the
    142  *  ready state.
    143  */
    144 
    145 RTEMS_INLINE_ROUTINE void _Priority_Remove_from_bit_map (
    146   Priority_Information *the_priority_map
    147 )
    148 {
    149   *the_priority_map->minor &= the_priority_map->block_minor;
    150   if ( *the_priority_map->minor == 0 )
    151     _Priority_Major_bit_map &= the_priority_map->block_major;
    152 }
    153 
    154 /**
    155  *  This function returns the priority of the highest priority
    156  *  ready thread.
    157  */
    158 
    159 RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_highest( void )
    160 {
    161   Priority_Bit_map_control minor;
    162   Priority_Bit_map_control major;
    163 
    164   _Bitfield_Find_first_bit( _Priority_Major_bit_map, major );
    165   _Bitfield_Find_first_bit( _Priority_Bit_map[major], minor );
    166 
    167   return (_Priority_Bits_index( major ) << 4) +
    168           _Priority_Bits_index( minor );
    169 }
    170 
    171 /**
    172  *  This routine initializes the_priority_map so that it
    173  *  contains the information necessary to manage a thread
    174  *  at new_priority.
    175  */
    176 
    177 RTEMS_INLINE_ROUTINE void _Priority_Initialize_information(
    178   Priority_Information *the_priority_map,
    179   Priority_Control      new_priority
    180 )
    181 {
    182   Priority_Bit_map_control major;
    183   Priority_Bit_map_control minor;
    184   Priority_Bit_map_control mask;
    185 
    186   major = _Priority_Major( new_priority );
    187   minor = _Priority_Minor( new_priority );
    188 
    189   the_priority_map->minor =
    190     &_Priority_Bit_map[ _Priority_Bits_index(major) ];
    191 
    192   mask = _Priority_Mask( major );
    193   the_priority_map->ready_major = mask;
    194   /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */
    195   the_priority_map->block_major = (Priority_Bit_map_control)(~((uint32_t)mask));
    196 
    197   mask = _Priority_Mask( minor );
    198   the_priority_map->ready_minor = mask;
    199   /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */
    200   the_priority_map->block_minor = (Priority_Bit_map_control)(~((uint32_t)mask));
    201 }
    202 
    203 /**
    204  *  This function returns true if the priority GROUP is empty, and
    205  *  false otherwise.
    206  */
    207 
    208 RTEMS_INLINE_ROUTINE bool _Priority_Is_group_empty (
    209   Priority_Control      the_priority
    210 )
    211 {
    212   return the_priority == 0;
    213 }
    21449
    21550/**@}*/
Note: See TracChangeset for help on using the changeset viewer.