Changeset a55e305 in rtems
- Timestamp:
- Jul 29, 2010, 5:52:10 PM (11 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 23bbc43
- Parents:
- a44edd15
- Location:
- cpukit
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/ChangeLog
ra44edd15 ra55e305 1 2010-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 1 24 2010-07-29 Joel Sherrill <joel.sherrilL@OARcorp.com> 2 25 -
cpukit/sapi/src/exinit.c
ra44edd15 ra55e305 43 43 #endif 44 44 #include <rtems/score/priority.h> 45 #include <rtems/score/prioritybitmap.h> 45 46 #include <rtems/score/thread.h> 46 47 #include <rtems/score/tod.h> … … 125 126 _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex ); 126 127 127 _Priority_ Handler_initialization();128 _Priority_bit_map_Handler_initialization(); 128 129 _Watchdog_Handler_initialization(); 129 130 _TOD_Handler_initialization(); -
cpukit/score/Makefile.am
ra44edd15 ra55e305 26 26 include/rtems/score/interr.h include/rtems/score/isr.h \ 27 27 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/sta tes.h include/rtems/score/sysstate.h \30 include/rtems/score/ thread.h include/rtems/score/threadq.h \31 include/rtems/score/thread sync.h include/rtems/score/timespec.h \32 include/rtems/score/times tamp.h include/rtems/score/timestamp64.h \33 include/rtems/score/t od.h include/rtems/score/tqdata.h \34 include/rtems/score/ userext.h include/rtems/score/watchdog.h \35 include/rtems/score/w kspace.h include/rtems/score/cpuopts.h \36 include/rtems/score/ basedefs.h28 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 37 37 38 38 if HAS_PTHREADS … … 54 54 inline/rtems/score/coresem.inl inline/rtems/score/heap.inl \ 55 55 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 61 62 62 63 if HAS_PTHREADS -
cpukit/score/include/rtems/score/bitfield.h
ra44edd15 ra55e305 91 91 \ 92 92 if ( __value < 0x100 ) \ 93 (_bit_number) = (Priority_ Bit_map_control)( __p[ __value ] + 8 ); \93 (_bit_number) = (Priority_bit_map_Control)( __p[ __value ] + 8 ); \ 94 94 else \ 95 (_bit_number) = (Priority_ Bit_map_control)( __p[ __value >> 8 ] ); \95 (_bit_number) = (Priority_bit_map_Control)( __p[ __value >> 8 ] ); \ 96 96 } 97 97 #endif -
cpukit/score/include/rtems/score/priority.h
ra44edd15 ra55e305 8 8 9 9 /* 10 * COPYRIGHT (c) 1989-20 06.10 * COPYRIGHT (c) 1989-2010. 11 11 * On-Line Applications Research Corporation (OAR). 12 12 * … … 68 68 69 69 /** 70 * The following record defines the information associated with71 * 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 /**87 70 * This variable contains the configured number of priorities 88 71 */ 89 72 extern uint8_t rtems_maximum_priority; 90 91 /**92 * Each sixteen bit entry in this array is associated with one of93 * 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 are98 * threads ready at a particular priority. The mapping of99 * individual priority levels to particular bits is processor100 * dependent as is the value of each bit used to indicate that101 * threads are ready at that priority.102 */103 SCORE_EXTERN Priority_Bit_map_control104 _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 major114 * or minor bit number.115 *116 * @param[in] _bit_number is the bit number for which we need a mask117 *118 * @return the priority bit mask119 *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 #endif125 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 #endif139 73 140 74 #ifndef __RTEMS_APPLICATION__ -
cpukit/score/include/rtems/score/thread.h
ra44edd15 ra55e305 71 71 #include <rtems/score/object.h> 72 72 #include <rtems/score/priority.h> 73 #include <rtems/score/prioritybitmap.h> 73 74 #include <rtems/score/stack.h> 74 75 #include <rtems/score/states.h> … … 393 394 Chain_Control *ready; 394 395 /** This field contains precalculated priority map indices. */ 395 Priority_ InformationPriority_map;396 Priority_bit_map_Information Priority_map; 396 397 /** This field contains information about the starting state of 397 398 * this thread. -
cpukit/score/inline/rtems/score/priority.inl
ra44edd15 ra55e305 29 29 */ 30 30 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 46 31 /** 47 32 * This function returns true if the_priority if valid for a … … 61 46 } 62 47 63 /**64 * This function returns the major portion of the_priority.65 */66 48 67 RTEMS_INLINE_ROUTINE Priority_Bit_map_control _Priority_Major (68 Priority_Control the_priority69 )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_priority80 )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 minor89 * number passed to it.90 */91 92 RTEMS_INLINE_ROUTINE Priority_Bit_map_control _Priority_Mask (93 uint32_t bit_number94 )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 mask105 )106 {107 return (Priority_Bit_map_control)(~mask);108 }109 110 111 /**112 * This function translates the bit numbers returned by the bit scan113 * of a priority bit field into something suitable for use as114 * a major or minor component of a priority.115 */116 117 RTEMS_INLINE_ROUTINE uint32_t _Priority_Bits_index (118 uint32_t bit_number119 )120 {121 return bit_number;122 }123 124 #endif125 126 /**127 * This routine uses the_priority_map to update the priority128 * 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_map133 )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 priority141 * bit maps to indicate that a thread has been removed from the142 * ready state.143 */144 145 RTEMS_INLINE_ROUTINE void _Priority_Remove_from_bit_map (146 Priority_Information *the_priority_map147 )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 priority156 * 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 it173 * contains the information necessary to manage a thread174 * at new_priority.175 */176 177 RTEMS_INLINE_ROUTINE void _Priority_Initialize_information(178 Priority_Information *the_priority_map,179 Priority_Control new_priority180 )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, and205 * false otherwise.206 */207 208 RTEMS_INLINE_ROUTINE bool _Priority_Is_group_empty (209 Priority_Control the_priority210 )211 {212 return the_priority == 0;213 }214 49 215 50 /**@}*/ -
cpukit/score/inline/rtems/score/thread.inl
ra44edd15 ra55e305 128 128 { 129 129 _Thread_Heir = (Thread_Control *) 130 _Thread_Ready_chain[ _Priority_ Get_highest() ].first;130 _Thread_Ready_chain[ _Priority_bit_map_Get_highest() ].first; 131 131 } 132 132 -
cpukit/score/preinstall.am
ra44edd15 ra55e305 108 108 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.h 109 109 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 112 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h 113 110 114 $(PROJECT_INCLUDE)/rtems/score/stack.h: include/rtems/score/stack.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) 111 115 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h … … 238 242 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.inl 239 243 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 246 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl 247 240 248 $(PROJECT_INCLUDE)/rtems/score/stack.inl: inline/rtems/score/stack.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) 241 249 $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.inl -
cpukit/score/src/threadchangepriority.c
ra44edd15 ra55e305 121 121 the_thread->current_state = _States_Clear( STATES_TRANSIENT, state ); 122 122 123 _Priority_ Add_to_bit_map( &the_thread->Priority_map );123 _Priority_bit_map_Add( &the_thread->Priority_map ); 124 124 if ( prepend_it ) 125 125 _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node ); -
cpukit/score/src/threadclearstate.c
ra44edd15 ra55e305 68 68 if ( _States_Is_ready( current_state ) ) { 69 69 70 _Priority_ Add_to_bit_map( &the_thread->Priority_map );70 _Priority_bit_map_Add( &the_thread->Priority_map ); 71 71 72 72 _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node); -
cpukit/score/src/threadready.c
ra44edd15 ra55e305 62 62 the_thread->current_state = STATES_READY; 63 63 64 _Priority_ Add_to_bit_map( &the_thread->Priority_map );64 _Priority_bit_map_Add( &the_thread->Priority_map ); 65 65 66 66 _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node ); -
cpukit/score/src/threadresume.c
ra44edd15 ra55e305 70 70 if ( _States_Is_ready( current_state ) ) { 71 71 72 _Priority_ Add_to_bit_map( &the_thread->Priority_map );72 _Priority_bit_map_Add( &the_thread->Priority_map ); 73 73 74 74 _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node); -
cpukit/score/src/threadsetpriority.c
ra44edd15 ra55e305 53 53 the_thread->ready = &_Thread_Ready_chain[ new_priority ]; 54 54 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 ); 56 59 } -
cpukit/score/src/threadsetstate.c
ra44edd15 ra55e305 71 71 72 72 _Chain_Initialize_empty( ready ); 73 _Priority_ Remove_from_bit_map( &the_thread->Priority_map );73 _Priority_bit_map_Remove( &the_thread->Priority_map ); 74 74 75 75 } else -
cpukit/score/src/threadsettransient.c
ra44edd15 ra55e305 67 67 68 68 _Chain_Initialize_empty( ready ); 69 _Priority_ Remove_from_bit_map( &the_thread->Priority_map );69 _Priority_bit_map_Remove( &the_thread->Priority_map ); 70 70 71 71 } else -
cpukit/score/src/threadsuspend.c
ra44edd15 ra55e305 69 69 70 70 _Chain_Initialize_empty( ready ); 71 _Priority_ Remove_from_bit_map( &the_thread->Priority_map );71 _Priority_bit_map_Remove( &the_thread->Priority_map ); 72 72 73 73 } else
Note: See TracChangeset
for help on using the changeset viewer.