Changeset a55e305 in rtems


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.
Location:
cpukit
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    ra44edd15 ra55e305  
     12010-07-29      Gedare Bloom <giddyup44@yahoo.com>
     2
     3        PR 1635/cpukit
     4        * sapi/src/exinit.c, score/Makefile.am, score/preinstall.am,
     5        score/include/rtems/score/bitfield.h,
     6        score/include/rtems/score/priority.h,
     7        score/include/rtems/score/thread.h,
     8        score/inline/rtems/score/priority.inl,
     9        score/inline/rtems/score/thread.inl,
     10        score/src/threadchangepriority.c, score/src/threadclearstate.c,
     11        score/src/threadready.c, score/src/threadresume.c,
     12        score/src/threadsetpriority.c, score/src/threadsetstate.c,
     13        score/src/threadsettransient.c, score/src/threadsuspend.c:
     14        Refactoring of priority handling, to isolate the bitmap
     15        implementation of priorities in the supercore so that priority
     16        management is a little more modular. This change is in anticipation
     17        of scheduler implementations that can select how they manage tracking
     18        priority levels / finding the highest priority ready task. Note that
     19        most of the changes here are simple renaming, to clarify the use of
     20        the bitmap-based priority management.
     21        * score/include/rtems/score/prioritybitmap.h,
     22        score/inline/rtems/score/prioritybitmap.inl: New files.
     23
    1242010-07-29      Joel Sherrill <joel.sherrilL@OARcorp.com>
    225
  • cpukit/sapi/src/exinit.c

    ra44edd15 ra55e305  
    4343#endif
    4444#include <rtems/score/priority.h>
     45#include <rtems/score/prioritybitmap.h>
    4546#include <rtems/score/thread.h>
    4647#include <rtems/score/tod.h>
     
    125126  _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex );
    126127
    127   _Priority_Handler_initialization();
     128  _Priority_bit_map_Handler_initialization();
    128129  _Watchdog_Handler_initialization();
    129130  _TOD_Handler_initialization();
  • cpukit/score/Makefile.am

    ra44edd15 ra55e305  
    2626    include/rtems/score/interr.h include/rtems/score/isr.h \
    2727    include/rtems/score/object.h include/rtems/score/percpu.h \
    28     include/rtems/score/priority.h include/rtems/score/stack.h \
    29     include/rtems/score/states.h include/rtems/score/sysstate.h \
    30     include/rtems/score/thread.h include/rtems/score/threadq.h \
    31     include/rtems/score/threadsync.h include/rtems/score/timespec.h \
    32     include/rtems/score/timestamp.h include/rtems/score/timestamp64.h \
    33     include/rtems/score/tod.h include/rtems/score/tqdata.h \
    34     include/rtems/score/userext.h include/rtems/score/watchdog.h \
    35     include/rtems/score/wkspace.h include/rtems/score/cpuopts.h \
    36     include/rtems/score/basedefs.h
     28    include/rtems/score/priority.h include/rtems/score/prioritybitmap.h \
     29    include/rtems/score/stack.h include/rtems/score/states.h \
     30    include/rtems/score/sysstate.h include/rtems/score/thread.h \
     31    include/rtems/score/threadq.h include/rtems/score/threadsync.h \
     32    include/rtems/score/timespec.h include/rtems/score/timestamp.h \
     33    include/rtems/score/timestamp64.h include/rtems/score/tod.h \
     34    include/rtems/score/tqdata.h include/rtems/score/userext.h \
     35    include/rtems/score/watchdog.h include/rtems/score/wkspace.h \
     36    include/rtems/score/cpuopts.h include/rtems/score/basedefs.h
    3737
    3838if HAS_PTHREADS
     
    5454    inline/rtems/score/coresem.inl inline/rtems/score/heap.inl \
    5555    inline/rtems/score/isr.inl inline/rtems/score/object.inl \
    56     inline/rtems/score/priority.inl inline/rtems/score/stack.inl \
    57     inline/rtems/score/states.inl inline/rtems/score/sysstate.inl \
    58     inline/rtems/score/thread.inl inline/rtems/score/threadq.inl \
    59     inline/rtems/score/tod.inl inline/rtems/score/tqdata.inl \
    60     inline/rtems/score/watchdog.inl inline/rtems/score/wkspace.inl
     56    inline/rtems/score/priority.inl inline/rtems/score/prioritybitmap.inl \
     57    inline/rtems/score/stack.inl inline/rtems/score/states.inl \
     58    inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \
     59    inline/rtems/score/threadq.inl inline/rtems/score/tod.inl \
     60    inline/rtems/score/tqdata.inl inline/rtems/score/watchdog.inl \
     61    inline/rtems/score/wkspace.inl
    6162
    6263if HAS_PTHREADS
  • cpukit/score/include/rtems/score/bitfield.h

    ra44edd15 ra55e305  
    9191    \
    9292    if ( __value < 0x100 ) \
    93       (_bit_number) = (Priority_Bit_map_control)( __p[ __value ] + 8 );  \
     93      (_bit_number) = (Priority_bit_map_Control)( __p[ __value ] + 8 );  \
    9494    else \
    95       (_bit_number) = (Priority_Bit_map_control)( __p[ __value >> 8 ] ); \
     95      (_bit_number) = (Priority_bit_map_Control)( __p[ __value >> 8 ] ); \
    9696  }
    9797#endif
  • cpukit/score/include/rtems/score/priority.h

    ra44edd15 ra55e305  
    88
    99/*
    10  *  COPYRIGHT (c) 1989-2006.
     10 *  COPYRIGHT (c) 1989-2010.
    1111 *  On-Line Applications Research Corporation (OAR).
    1212 *
     
    6868
    6969/**
    70  *  The following record defines the information associated with
    71  *  each thread to manage its interaction with the priority bit maps.
    72  */
    73 typedef struct {
    74   /** This is the address of minor bit map slot. */
    75   Priority_Bit_map_control *minor;
    76   /** This is the priority bit map ready mask. */
    77   Priority_Bit_map_control  ready_major;
    78   /** This is the priority bit map ready mask. */
    79   Priority_Bit_map_control  ready_minor;
    80   /** This is the priority bit map block mask. */
    81   Priority_Bit_map_control  block_major;
    82   /** This is the priority bit map block mask. */
    83   Priority_Bit_map_control  block_minor;
    84 }   Priority_Information;
    85 
    86 /**
    8770 *  This variable contains the configured number of priorities
    8871 */
    8972extern uint8_t rtems_maximum_priority;
    90 
    91 /**
    92  *  Each sixteen bit entry in this array is associated with one of
    93  *  the sixteen entries in the Priority Bit map.
    94  */
    95 SCORE_EXTERN volatile Priority_Bit_map_control _Priority_Major_bit_map;
    96 
    97 /** Each bit in the Priority Bitmap indicates whether or not there are
    98  *  threads ready at a particular priority.  The mapping of
    99  *  individual priority levels to particular bits is processor
    100  *  dependent as is the value of each bit used to indicate that
    101  *  threads are ready at that priority.
    102  */
    103 SCORE_EXTERN Priority_Bit_map_control
    104                _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT;
    105 
    106 /*
    107  *  The definition of the Priority_Bit_map_control type is CPU dependent.
    108  *
    109  */
    110 
    111 #if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE )
    112 /**
    113  *  This method returns the priority bit mask for the specified major
    114  *  or minor bit number.
    115  *
    116  *  @param[in] _bit_number is the bit number for which we need a mask
    117  *
    118  *  @return the priority bit mask
    119  *
    120  *  @note This may simply be a pass through to a CPU dependent implementation.
    121  */
    122 #define _Priority_Mask( _bit_number ) \
    123   _CPU_Priority_Mask( _bit_number )
    124 #endif
    125 
    126 #if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE )
    127 /**
    128  *  This method returns the bit index position for the specified priority.
    129  *
    130  *  @param[in] _priority is the priority for which we need the index.
    131  *
    132  *  @return This method returns the array index into the priority bit map.
    133  *
    134  *  @note This may simply be a pass through to a CPU dependent implementation.
    135  */
    136 #define _Priority_Bits_index( _priority ) \
    137   _CPU_Priority_bits_index( _priority )
    138 #endif
    13973
    14074#ifndef __RTEMS_APPLICATION__
  • cpukit/score/include/rtems/score/thread.h

    ra44edd15 ra55e305  
    7171#include <rtems/score/object.h>
    7272#include <rtems/score/priority.h>
     73#include <rtems/score/prioritybitmap.h>
    7374#include <rtems/score/stack.h>
    7475#include <rtems/score/states.h>
     
    393394  Chain_Control                        *ready;
    394395  /** This field contains precalculated priority map indices. */
    395   Priority_Information                  Priority_map;
     396  Priority_bit_map_Information          Priority_map;
    396397  /** This field contains information about the starting state of
    397398   *  this thread.
  • 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/**@}*/
  • cpukit/score/inline/rtems/score/thread.inl

    ra44edd15 ra55e305  
    128128{
    129129  _Thread_Heir = (Thread_Control *)
    130     _Thread_Ready_chain[ _Priority_Get_highest() ].first;
     130    _Thread_Ready_chain[ _Priority_bit_map_Get_highest() ].first;
    131131}
    132132
  • cpukit/score/preinstall.am

    ra44edd15 ra55e305  
    108108PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.h
    109109
     110$(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h: include/rtems/score/prioritybitmap.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     111        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h
     112PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h
     113
    110114$(PROJECT_INCLUDE)/rtems/score/stack.h: include/rtems/score/stack.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    111115        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h
     
    238242PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.inl
    239243
     244$(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl: inline/rtems/score/prioritybitmap.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     245        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl
     246PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl
     247
    240248$(PROJECT_INCLUDE)/rtems/score/stack.inl: inline/rtems/score/stack.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    241249        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.inl
  • cpukit/score/src/threadchangepriority.c

    ra44edd15 ra55e305  
    121121    the_thread->current_state = _States_Clear( STATES_TRANSIENT, state );
    122122
    123     _Priority_Add_to_bit_map( &the_thread->Priority_map );
     123    _Priority_bit_map_Add( &the_thread->Priority_map );
    124124    if ( prepend_it )
    125125      _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node );
  • cpukit/score/src/threadclearstate.c

    ra44edd15 ra55e305  
    6868      if ( _States_Is_ready( current_state ) ) {
    6969
    70         _Priority_Add_to_bit_map( &the_thread->Priority_map );
     70        _Priority_bit_map_Add( &the_thread->Priority_map );
    7171
    7272        _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node);
  • cpukit/score/src/threadready.c

    ra44edd15 ra55e305  
    6262  the_thread->current_state = STATES_READY;
    6363
    64   _Priority_Add_to_bit_map( &the_thread->Priority_map );
     64  _Priority_bit_map_Add( &the_thread->Priority_map );
    6565
    6666  _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node );
  • cpukit/score/src/threadresume.c

    ra44edd15 ra55e305  
    7070    if ( _States_Is_ready( current_state ) ) {
    7171
    72       _Priority_Add_to_bit_map( &the_thread->Priority_map );
     72      _Priority_bit_map_Add( &the_thread->Priority_map );
    7373
    7474      _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node);
  • cpukit/score/src/threadsetpriority.c

    ra44edd15 ra55e305  
    5353  the_thread->ready            = &_Thread_Ready_chain[ new_priority ];
    5454
    55   _Priority_Initialize_information( &the_thread->Priority_map, new_priority );
     55  _Priority_bit_map_Initialize_information(
     56      &the_thread->Priority_map,
     57      new_priority
     58  );
    5659}
  • cpukit/score/src/threadsetstate.c

    ra44edd15 ra55e305  
    7171
    7272    _Chain_Initialize_empty( ready );
    73     _Priority_Remove_from_bit_map( &the_thread->Priority_map );
     73    _Priority_bit_map_Remove( &the_thread->Priority_map );
    7474
    7575  } else
  • cpukit/score/src/threadsettransient.c

    ra44edd15 ra55e305  
    6767
    6868      _Chain_Initialize_empty( ready );
    69       _Priority_Remove_from_bit_map( &the_thread->Priority_map );
     69      _Priority_bit_map_Remove( &the_thread->Priority_map );
    7070
    7171    } else
  • cpukit/score/src/threadsuspend.c

    ra44edd15 ra55e305  
    6969
    7070    _Chain_Initialize_empty( ready );
    71     _Priority_Remove_from_bit_map( &the_thread->Priority_map );
     71    _Priority_bit_map_Remove( &the_thread->Priority_map );
    7272
    7373  } else
Note: See TracChangeset for help on using the changeset viewer.