diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-29 17:52:10 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2010-07-29 17:52:10 +0000 |
commit | a55e305ed3406b935a24ceb9becdff58a1a87948 (patch) | |
tree | b4745978fb84fecc82b1b3d0d0cb7aa0eec8d4a7 /cpukit | |
parent | 2010-07-29 Gedare Bloom <giddyup44@yahoo.com> (diff) | |
download | rtems-a55e305ed3406b935a24ceb9becdff58a1a87948.tar.bz2 |
2010-07-29 Gedare Bloom <giddyup44@yahoo.com>
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.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/ChangeLog | 23 | ||||
-rw-r--r-- | cpukit/sapi/src/exinit.c | 3 | ||||
-rw-r--r-- | cpukit/score/Makefile.am | 29 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/bitfield.h | 4 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/priority.h | 68 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/prioritybitmap.h | 125 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/thread.h | 3 | ||||
-rw-r--r-- | cpukit/score/inline/rtems/score/priority.inl | 165 | ||||
-rw-r--r-- | cpukit/score/inline/rtems/score/prioritybitmap.inl | 193 | ||||
-rw-r--r-- | cpukit/score/inline/rtems/score/thread.inl | 2 | ||||
-rw-r--r-- | cpukit/score/preinstall.am | 8 | ||||
-rw-r--r-- | cpukit/score/src/threadchangepriority.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadclearstate.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadready.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadresume.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadsetpriority.c | 5 | ||||
-rw-r--r-- | cpukit/score/src/threadsetstate.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadsettransient.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadsuspend.c | 2 |
19 files changed, 383 insertions, 259 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index a8d0aca787..3133e9f5aa 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,26 @@ +2010-07-29 Gedare Bloom <giddyup44@yahoo.com> + + 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. + 2010-07-29 Joel Sherrill <joel.sherrilL@OARcorp.com> * posix/src/psignalunblockthread.c: Clean up and simplify. diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c index deefd9a70d..1185b74e4a 100644 --- a/cpukit/sapi/src/exinit.c +++ b/cpukit/sapi/src/exinit.c @@ -42,6 +42,7 @@ #include <rtems/score/mpci.h> #endif #include <rtems/score/priority.h> +#include <rtems/score/prioritybitmap.h> #include <rtems/score/thread.h> #include <rtems/score/tod.h> #include <rtems/score/userext.h> @@ -124,7 +125,7 @@ void rtems_initialize_data_structures(void) _API_Mutex_Initialization( 1 ); _API_Mutex_Allocate( &_RTEMS_Allocator_Mutex ); - _Priority_Handler_initialization(); + _Priority_bit_map_Handler_initialization(); _Watchdog_Handler_initialization(); _TOD_Handler_initialization(); diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 01978fce3a..43d53e0526 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -25,15 +25,15 @@ include_rtems_score_HEADERS = include/rtems/score/address.h \ include/rtems/score/heap.h include/rtems/score/protectedheap.h \ include/rtems/score/interr.h include/rtems/score/isr.h \ include/rtems/score/object.h include/rtems/score/percpu.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/threadq.h \ - include/rtems/score/threadsync.h include/rtems/score/timespec.h \ - include/rtems/score/timestamp.h include/rtems/score/timestamp64.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 include/rtems/score/cpuopts.h \ - include/rtems/score/basedefs.h + include/rtems/score/priority.h include/rtems/score/prioritybitmap.h \ + include/rtems/score/stack.h include/rtems/score/states.h \ + include/rtems/score/sysstate.h include/rtems/score/thread.h \ + include/rtems/score/threadq.h include/rtems/score/threadsync.h \ + include/rtems/score/timespec.h include/rtems/score/timestamp.h \ + include/rtems/score/timestamp64.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 \ + include/rtems/score/cpuopts.h include/rtems/score/basedefs.h if HAS_PTHREADS include_rtems_score_HEADERS += include/rtems/score/corespinlock.h \ @@ -53,11 +53,12 @@ include_rtems_score_HEADERS += inline/rtems/score/address.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/object.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/threadq.inl \ - inline/rtems/score/tod.inl inline/rtems/score/tqdata.inl \ - inline/rtems/score/watchdog.inl inline/rtems/score/wkspace.inl + inline/rtems/score/priority.inl inline/rtems/score/prioritybitmap.inl \ + inline/rtems/score/stack.inl inline/rtems/score/states.inl \ + inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \ + inline/rtems/score/threadq.inl inline/rtems/score/tod.inl \ + inline/rtems/score/tqdata.inl inline/rtems/score/watchdog.inl \ + inline/rtems/score/wkspace.inl if HAS_PTHREADS include_rtems_score_HEADERS += inline/rtems/score/corespinlock.inl \ diff --git a/cpukit/score/include/rtems/score/bitfield.h b/cpukit/score/include/rtems/score/bitfield.h index c0fa9b6b56..43f8fd09c4 100644 --- a/cpukit/score/include/rtems/score/bitfield.h +++ b/cpukit/score/include/rtems/score/bitfield.h @@ -90,9 +90,9 @@ const unsigned char __log2table[256] = { register const unsigned char *__p = __log2table; \ \ if ( __value < 0x100 ) \ - (_bit_number) = (Priority_Bit_map_control)( __p[ __value ] + 8 ); \ + (_bit_number) = (Priority_bit_map_Control)( __p[ __value ] + 8 ); \ else \ - (_bit_number) = (Priority_Bit_map_control)( __p[ __value >> 8 ] ); \ + (_bit_number) = (Priority_bit_map_Control)( __p[ __value >> 8 ] ); \ } #endif diff --git a/cpukit/score/include/rtems/score/priority.h b/cpukit/score/include/rtems/score/priority.h index 5a1dccaecc..05dc939d84 100644 --- a/cpukit/score/include/rtems/score/priority.h +++ b/cpukit/score/include/rtems/score/priority.h @@ -7,7 +7,7 @@ */ /* - * COPYRIGHT (c) 1989-2006. + * COPYRIGHT (c) 1989-2010. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -67,76 +67,10 @@ typedef uint32_t Priority_Control; #define PRIORITY_MAXIMUM rtems_maximum_priority /** - * The following record defines the information associated with - * each thread to manage its interaction with the priority bit maps. - */ -typedef struct { - /** This is the address of minor bit map slot. */ - Priority_Bit_map_control *minor; - /** This is the priority bit map ready mask. */ - Priority_Bit_map_control ready_major; - /** This is the priority bit map ready mask. */ - Priority_Bit_map_control ready_minor; - /** This is the priority bit map block mask. */ - Priority_Bit_map_control block_major; - /** This is the priority bit map block mask. */ - Priority_Bit_map_control block_minor; -} Priority_Information; - -/** * This variable contains the configured number of priorities */ extern uint8_t rtems_maximum_priority; -/** - * Each sixteen bit entry in this array is associated with one of - * the sixteen entries in the Priority Bit map. - */ -SCORE_EXTERN volatile Priority_Bit_map_control _Priority_Major_bit_map; - -/** Each bit in the Priority Bitmap indicates whether or not there are - * threads ready at a particular priority. The mapping of - * individual priority levels to particular bits is processor - * dependent as is the value of each bit used to indicate that - * threads are ready at that priority. - */ -SCORE_EXTERN Priority_Bit_map_control - _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT; - -/* - * The definition of the Priority_Bit_map_control type is CPU dependent. - * - */ - -#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) -/** - * This method returns the priority bit mask for the specified major - * or minor bit number. - * - * @param[in] _bit_number is the bit number for which we need a mask - * - * @return the priority bit mask - * - * @note This may simply be a pass through to a CPU dependent implementation. - */ -#define _Priority_Mask( _bit_number ) \ - _CPU_Priority_Mask( _bit_number ) -#endif - -#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) -/** - * This method returns the bit index position for the specified priority. - * - * @param[in] _priority is the priority for which we need the index. - * - * @return This method returns the array index into the priority bit map. - * - * @note This may simply be a pass through to a CPU dependent implementation. - */ -#define _Priority_Bits_index( _priority ) \ - _CPU_Priority_bits_index( _priority ) -#endif - #ifndef __RTEMS_APPLICATION__ #include <rtems/score/priority.inl> #endif diff --git a/cpukit/score/include/rtems/score/prioritybitmap.h b/cpukit/score/include/rtems/score/prioritybitmap.h new file mode 100644 index 0000000000..cd712952b2 --- /dev/null +++ b/cpukit/score/include/rtems/score/prioritybitmap.h @@ -0,0 +1,125 @@ +/** + * @file rtems/score/prioritybitmap.h + * + * This include file contains all thread priority manipulation routines for + * the bit map priority queue implementation. + */ + +/* + * COPYRIGHT (c) 1989-2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_SCORE_PRIORITYBITMAP_H +#define _RTEMS_SCORE_PRIORITYBITMAP_H + +/** + * @addtogroup ScorePriority + * + */ +/**@{*/ + +/* + * Processor specific information. + */ +#include <rtems/score/cpu.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/score/priority.h> + +/* + * TODO: + * These should only be instantiated if using the bit map handler. The + * logical place for this is in confdefs.h when a scheduler that uses the + * bit map handler is configured. + */ + +/** + * Each sixteen bit entry in this array is associated with one of + * the sixteen entries in the Priority Bit map. + */ +SCORE_EXTERN volatile Priority_bit_map_Control _Priority_Major_bit_map; + +/** Each bit in the Priority Bitmap indicates whether or not there are + * threads ready at a particular priority. The mapping of + * individual priority levels to particular bits is processor + * dependent as is the value of each bit used to indicate that + * threads are ready at that priority. + */ +SCORE_EXTERN Priority_bit_map_Control + _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT; + +/* + * The definition of the Priority_bit_map_Control type is CPU dependent. + * + */ + +/** + * The following record defines the information associated with + * each thread to manage its interaction with the priority bit maps. + */ +typedef struct { + /** This is the address of minor bit map slot. */ + Priority_bit_map_Control *minor; + /** This is the priority bit map ready mask. */ + Priority_bit_map_Control ready_major; + /** This is the priority bit map ready mask. */ + Priority_bit_map_Control ready_minor; + /** This is the priority bit map block mask. */ + Priority_bit_map_Control block_major; + /** This is the priority bit map block mask. */ + Priority_bit_map_Control block_minor; +} Priority_bit_map_Information; + + +#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) +/** + * This method returns the priority bit mask for the specified major + * or minor bit number. + * + * @param[in] _bit_number is the bit number for which we need a mask + * + * @return the priority bit mask + * + * @note This may simply be a pass through to a CPU dependent implementation. + */ +#define _Priority_Mask( _bit_number ) \ + _CPU_Priority_Mask( _bit_number ) +#endif + +#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) +/** + * This method returns the bit index position for the specified priority. + * + * @param[in] _priority is the priority for which we need the index. + * + * @return This method returns the array index into the priority bit map. + * + * @note This may simply be a pass through to a CPU dependent implementation. + */ +#define _Priority_Bits_index( _priority ) \ + _CPU_Priority_bits_index( _priority ) +#endif + +#ifndef __RTEMS_APPLICATION__ +#include <rtems/score/prioritybitmap.inl> +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index ca4b04fa22..9565458bb8 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -70,6 +70,7 @@ extern "C" { #endif #include <rtems/score/object.h> #include <rtems/score/priority.h> +#include <rtems/score/prioritybitmap.h> #include <rtems/score/stack.h> #include <rtems/score/states.h> #include <rtems/score/tod.h> @@ -392,7 +393,7 @@ struct Thread_Control_struct { /** This field points to the Ready FIFO for this priority. */ Chain_Control *ready; /** This field contains precalculated priority map indices. */ - Priority_Information Priority_map; + Priority_bit_map_Information Priority_map; /** This field contains information about the starting state of * this thread. */ diff --git a/cpukit/score/inline/rtems/score/priority.inl b/cpukit/score/inline/rtems/score/priority.inl index f03570e27d..089a81ebda 100644 --- a/cpukit/score/inline/rtems/score/priority.inl +++ b/cpukit/score/inline/rtems/score/priority.inl @@ -28,21 +28,6 @@ * @{ */ -#include <rtems/score/bitfield.h> - -/** - * This routine performs the initialization necessary for this handler. - */ - -RTEMS_INLINE_ROUTINE void _Priority_Handler_initialization( void ) -{ - int index; - - _Priority_Major_bit_map = 0; - for ( index=0 ; index <16 ; index++ ) - _Priority_Bit_map[ index ] = 0; -} - /** * This function returns true if the_priority if valid for a * user task, and false otherwise. @@ -60,157 +45,7 @@ RTEMS_INLINE_ROUTINE bool _Priority_Is_valid ( return ( the_priority <= PRIORITY_MAXIMUM ); } -/** - * This function returns the major portion of the_priority. - */ -RTEMS_INLINE_ROUTINE Priority_Bit_map_control _Priority_Major ( - Priority_Control the_priority -) -{ - return (Priority_Bit_map_control)( the_priority / 16 ); -} - -/** - * This function returns the minor portion of the_priority. - */ - -RTEMS_INLINE_ROUTINE Priority_Bit_map_control _Priority_Minor ( - Priority_Control the_priority -) -{ - return (Priority_Bit_map_control)( the_priority % 16 ); -} - -#if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE ) - -/** - * This function returns the mask associated with the major or minor - * number passed to it. - */ - -RTEMS_INLINE_ROUTINE Priority_Bit_map_control _Priority_Mask ( - uint32_t bit_number -) -{ - return (Priority_Bit_map_control)(0x8000u >> bit_number); -} - -/** - * This function returns the mask bit inverted. - */ - -RTEMS_INLINE_ROUTINE Priority_Bit_map_control _Priority_Mask_invert ( - uint32_t mask -) -{ - return (Priority_Bit_map_control)(~mask); -} - - -/** - * This function translates the bit numbers returned by the bit scan - * of a priority bit field into something suitable for use as - * a major or minor component of a priority. - */ - -RTEMS_INLINE_ROUTINE uint32_t _Priority_Bits_index ( - uint32_t bit_number -) -{ - return bit_number; -} - -#endif - -/** - * This routine uses the_priority_map to update the priority - * bit maps to indicate that a thread has been readied. - */ - -RTEMS_INLINE_ROUTINE void _Priority_Add_to_bit_map ( - Priority_Information *the_priority_map -) -{ - *the_priority_map->minor |= the_priority_map->ready_minor; - _Priority_Major_bit_map |= the_priority_map->ready_major; -} - -/** - * This routine uses the_priority_map to update the priority - * bit maps to indicate that a thread has been removed from the - * ready state. - */ - -RTEMS_INLINE_ROUTINE void _Priority_Remove_from_bit_map ( - Priority_Information *the_priority_map -) -{ - *the_priority_map->minor &= the_priority_map->block_minor; - if ( *the_priority_map->minor == 0 ) - _Priority_Major_bit_map &= the_priority_map->block_major; -} - -/** - * This function returns the priority of the highest priority - * ready thread. - */ - -RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_highest( void ) -{ - Priority_Bit_map_control minor; - Priority_Bit_map_control major; - - _Bitfield_Find_first_bit( _Priority_Major_bit_map, major ); - _Bitfield_Find_first_bit( _Priority_Bit_map[major], minor ); - - return (_Priority_Bits_index( major ) << 4) + - _Priority_Bits_index( minor ); -} - -/** - * This routine initializes the_priority_map so that it - * contains the information necessary to manage a thread - * at new_priority. - */ - -RTEMS_INLINE_ROUTINE void _Priority_Initialize_information( - Priority_Information *the_priority_map, - Priority_Control new_priority -) -{ - Priority_Bit_map_control major; - Priority_Bit_map_control minor; - Priority_Bit_map_control mask; - - major = _Priority_Major( new_priority ); - minor = _Priority_Minor( new_priority ); - - the_priority_map->minor = - &_Priority_Bit_map[ _Priority_Bits_index(major) ]; - - mask = _Priority_Mask( major ); - the_priority_map->ready_major = mask; - /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */ - the_priority_map->block_major = (Priority_Bit_map_control)(~((uint32_t)mask)); - - mask = _Priority_Mask( minor ); - the_priority_map->ready_minor = mask; - /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */ - the_priority_map->block_minor = (Priority_Bit_map_control)(~((uint32_t)mask)); -} - -/** - * This function returns true if the priority GROUP is empty, and - * false otherwise. - */ - -RTEMS_INLINE_ROUTINE bool _Priority_Is_group_empty ( - Priority_Control the_priority -) -{ - return the_priority == 0; -} /**@}*/ diff --git a/cpukit/score/inline/rtems/score/prioritybitmap.inl b/cpukit/score/inline/rtems/score/prioritybitmap.inl new file mode 100644 index 0000000000..7938a38afc --- /dev/null +++ b/cpukit/score/inline/rtems/score/prioritybitmap.inl @@ -0,0 +1,193 @@ +/** + * @file rtems/score/prioritybitmap.inl + * + * This file contains the static inline implementation of all inlined + * routines in the Priority Handler bit map implementation + */ + +/* + * COPYRIGHT (c) 1989-2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifndef _RTEMS_SCORE_PRIORITYBITMAP_H +# error "Never use <rtems/score/prioritybitmap.inl> directly; include <rtems/score/prioritybitmap.h> instead." +#endif + +#ifndef _RTEMS_SCORE_PRIORITYBITMAP_INL +#define _RTEMS_SCORE_PRIORITYBITMAP_INL + +/** + * @addtogroup ScorePriority + * @{ + */ + +#include <rtems/score/bitfield.h> + +/** + * This function returns the major portion of the_priority. + */ + +RTEMS_INLINE_ROUTINE Priority_bit_map_Control _Priority_Major ( + Priority_Control the_priority +) +{ + return (Priority_bit_map_Control)( the_priority / 16 ); +} + +/** + * This function returns the minor portion of the_priority. + */ + +RTEMS_INLINE_ROUTINE Priority_bit_map_Control _Priority_Minor ( + Priority_Control the_priority +) +{ + return (Priority_bit_map_Control)( the_priority % 16 ); +} + +#if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE ) + +/** + * This function returns the mask associated with the major or minor + * number passed to it. + */ + +RTEMS_INLINE_ROUTINE Priority_bit_map_Control _Priority_Mask ( + uint32_t bit_number +) +{ + return (Priority_bit_map_Control)(0x8000u >> bit_number); +} + +/** + * This function returns the mask bit inverted. + */ + +RTEMS_INLINE_ROUTINE Priority_bit_map_Control _Priority_Mask_invert ( + uint32_t mask +) +{ + return (Priority_bit_map_Control)(~mask); +} + + +/** + * This function translates the bit numbers returned by the bit scan + * of a priority bit field into something suitable for use as + * a major or minor component of a priority. + */ + +RTEMS_INLINE_ROUTINE uint32_t _Priority_Bits_index ( + uint32_t bit_number +) +{ + return bit_number; +} + +#endif + +/** + * Priority Queue implemented by bit map + */ + +/** + * This routine performs the initialization necessary for this handler. + */ + +RTEMS_INLINE_ROUTINE void _Priority_bit_map_Handler_initialization( void ) +{ + int index; + + _Priority_Major_bit_map = 0; + for ( index=0 ; index <16 ; index++ ) + _Priority_Bit_map[ index ] = 0; +} + +/** + * This routine uses the_priority_map to update the priority + * bit maps to indicate that a thread has been readied. + */ + +RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add ( + Priority_bit_map_Information *the_priority_map +) +{ + *the_priority_map->minor |= the_priority_map->ready_minor; + _Priority_Major_bit_map |= the_priority_map->ready_major; +} + +/** + * This routine uses the_priority_map to update the priority + * bit maps to indicate that a thread has been removed from the + * ready state. + */ + +RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove ( + Priority_bit_map_Information *the_priority_map +) +{ + *the_priority_map->minor &= the_priority_map->block_minor; + if ( *the_priority_map->minor == 0 ) + _Priority_Major_bit_map &= the_priority_map->block_major; +} + +/** + * This function returns the priority of the highest priority + * ready thread. + */ + +RTEMS_INLINE_ROUTINE Priority_Control _Priority_bit_map_Get_highest( void ) +{ + Priority_bit_map_Control minor; + Priority_bit_map_Control major; + + _Bitfield_Find_first_bit( _Priority_Major_bit_map, major ); + _Bitfield_Find_first_bit( _Priority_Bit_map[major], minor ); + + return (_Priority_Bits_index( major ) << 4) + + _Priority_Bits_index( minor ); +} + +/** + * This routine initializes the_priority_map so that it + * contains the information necessary to manage a thread + * at new_priority. + */ + +RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information( + Priority_bit_map_Information *the_priority_map, + Priority_Control new_priority +) +{ + Priority_bit_map_Control major; + Priority_bit_map_Control minor; + Priority_bit_map_Control mask; + + major = _Priority_Major( new_priority ); + minor = _Priority_Minor( new_priority ); + + the_priority_map->minor = + &_Priority_Bit_map[ _Priority_Bits_index(major) ]; + + mask = _Priority_Mask( major ); + the_priority_map->ready_major = mask; + /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */ + the_priority_map->block_major = (Priority_bit_map_Control)(~((uint32_t)mask)); + + mask = _Priority_Mask( minor ); + the_priority_map->ready_minor = mask; + /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */ + the_priority_map->block_minor = (Priority_bit_map_Control)(~((uint32_t)mask)); +} + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/score/inline/rtems/score/thread.inl b/cpukit/score/inline/rtems/score/thread.inl index 48721fe541..d008989915 100644 --- a/cpukit/score/inline/rtems/score/thread.inl +++ b/cpukit/score/inline/rtems/score/thread.inl @@ -127,7 +127,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Restart_self( void ) RTEMS_INLINE_ROUTINE void _Thread_Calculate_heir( void ) { _Thread_Heir = (Thread_Control *) - _Thread_Ready_chain[ _Priority_Get_highest() ].first; + _Thread_Ready_chain[ _Priority_bit_map_Get_highest() ].first; } /** diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am index 71e489d02f..9768f8c81d 100644 --- a/cpukit/score/preinstall.am +++ b/cpukit/score/preinstall.am @@ -107,6 +107,10 @@ $(PROJECT_INCLUDE)/rtems/score/priority.h: include/rtems/score/priority.h $(PROJ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/priority.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.h +$(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h: include/rtems/score/prioritybitmap.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h + $(PROJECT_INCLUDE)/rtems/score/stack.h: include/rtems/score/stack.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.h @@ -237,6 +241,10 @@ $(PROJECT_INCLUDE)/rtems/score/priority.inl: inline/rtems/score/priority.inl $(P $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/priority.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.inl +$(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl: inline/rtems/score/prioritybitmap.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.inl + $(PROJECT_INCLUDE)/rtems/score/stack.inl: inline/rtems/score/stack.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.inl PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.inl diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c index 2215be03a6..5e14edd575 100644 --- a/cpukit/score/src/threadchangepriority.c +++ b/cpukit/score/src/threadchangepriority.c @@ -120,7 +120,7 @@ void _Thread_Change_priority( */ the_thread->current_state = _States_Clear( STATES_TRANSIENT, state ); - _Priority_Add_to_bit_map( &the_thread->Priority_map ); + _Priority_bit_map_Add( &the_thread->Priority_map ); if ( prepend_it ) _Chain_Prepend_unprotected( the_thread->ready, &the_thread->Object.Node ); else diff --git a/cpukit/score/src/threadclearstate.c b/cpukit/score/src/threadclearstate.c index 872d57cc66..9f89f1a736 100644 --- a/cpukit/score/src/threadclearstate.c +++ b/cpukit/score/src/threadclearstate.c @@ -67,7 +67,7 @@ void _Thread_Clear_state( if ( _States_Is_ready( current_state ) ) { - _Priority_Add_to_bit_map( &the_thread->Priority_map ); + _Priority_bit_map_Add( &the_thread->Priority_map ); _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node); diff --git a/cpukit/score/src/threadready.c b/cpukit/score/src/threadready.c index c236f61cf3..ea6f349704 100644 --- a/cpukit/score/src/threadready.c +++ b/cpukit/score/src/threadready.c @@ -61,7 +61,7 @@ void _Thread_Ready( the_thread->current_state = STATES_READY; - _Priority_Add_to_bit_map( &the_thread->Priority_map ); + _Priority_bit_map_Add( &the_thread->Priority_map ); _Chain_Append_unprotected( the_thread->ready, &the_thread->Object.Node ); diff --git a/cpukit/score/src/threadresume.c b/cpukit/score/src/threadresume.c index fe8b6842de..f1ad9ab0bc 100644 --- a/cpukit/score/src/threadresume.c +++ b/cpukit/score/src/threadresume.c @@ -69,7 +69,7 @@ void _Thread_Resume( if ( _States_Is_ready( current_state ) ) { - _Priority_Add_to_bit_map( &the_thread->Priority_map ); + _Priority_bit_map_Add( &the_thread->Priority_map ); _Chain_Append_unprotected(the_thread->ready, &the_thread->Object.Node); diff --git a/cpukit/score/src/threadsetpriority.c b/cpukit/score/src/threadsetpriority.c index ba1482f5b5..cfe069d4ae 100644 --- a/cpukit/score/src/threadsetpriority.c +++ b/cpukit/score/src/threadsetpriority.c @@ -52,5 +52,8 @@ void _Thread_Set_priority( the_thread->current_priority = new_priority; the_thread->ready = &_Thread_Ready_chain[ new_priority ]; - _Priority_Initialize_information( &the_thread->Priority_map, new_priority ); + _Priority_bit_map_Initialize_information( + &the_thread->Priority_map, + new_priority + ); } diff --git a/cpukit/score/src/threadsetstate.c b/cpukit/score/src/threadsetstate.c index 911586b502..e1bb9d80db 100644 --- a/cpukit/score/src/threadsetstate.c +++ b/cpukit/score/src/threadsetstate.c @@ -70,7 +70,7 @@ void _Thread_Set_state( if ( _Chain_Has_only_one_node( ready ) ) { _Chain_Initialize_empty( ready ); - _Priority_Remove_from_bit_map( &the_thread->Priority_map ); + _Priority_bit_map_Remove( &the_thread->Priority_map ); } else _Chain_Extract_unprotected( &the_thread->Object.Node ); diff --git a/cpukit/score/src/threadsettransient.c b/cpukit/score/src/threadsettransient.c index ab0a1d451d..36f60a6077 100644 --- a/cpukit/score/src/threadsettransient.c +++ b/cpukit/score/src/threadsettransient.c @@ -66,7 +66,7 @@ void _Thread_Set_transient( if ( _Chain_Has_only_one_node( ready ) ) { _Chain_Initialize_empty( ready ); - _Priority_Remove_from_bit_map( &the_thread->Priority_map ); + _Priority_bit_map_Remove( &the_thread->Priority_map ); } else _Chain_Extract_unprotected( &the_thread->Object.Node ); diff --git a/cpukit/score/src/threadsuspend.c b/cpukit/score/src/threadsuspend.c index dd3f287e52..27540ecfef 100644 --- a/cpukit/score/src/threadsuspend.c +++ b/cpukit/score/src/threadsuspend.c @@ -68,7 +68,7 @@ void _Thread_Suspend( if ( _Chain_Has_only_one_node( ready ) ) { _Chain_Initialize_empty( ready ); - _Priority_Remove_from_bit_map( &the_thread->Priority_map ); + _Priority_bit_map_Remove( &the_thread->Priority_map ); } else _Chain_Extract_unprotected( &the_thread->Object.Node ); |