From a55e305ed3406b935a24ceb9becdff58a1a87948 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 29 Jul 2010 17:52:10 +0000 Subject: 2010-07-29 Gedare Bloom 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. --- cpukit/score/include/rtems/score/bitfield.h | 4 +- cpukit/score/include/rtems/score/priority.h | 68 +----------- cpukit/score/include/rtems/score/prioritybitmap.h | 125 ++++++++++++++++++++++ cpukit/score/include/rtems/score/thread.h | 3 +- 4 files changed, 130 insertions(+), 70 deletions(-) create mode 100644 cpukit/score/include/rtems/score/prioritybitmap.h (limited to 'cpukit/score/include') 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 @@ -66,77 +66,11 @@ typedef uint32_t Priority_Control; /** This defines the lowest (least important) thread priority. */ #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 #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 + + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * 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 +#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 #include +#include #include #include #include @@ -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. */ -- cgit v1.2.3