score: Add and use _Per_CPU_Is_ISR_in_progress()

Add _Per_CPU_Is_ISR_in_progress() as an optimized version of
_ISR_Is_in_progress().
This commit is contained in:
Sebastian Huber
2021-05-14 17:33:24 +02:00
parent 6f2c8f32e6
commit 2cc25cf1b2
4 changed files with 22 additions and 13 deletions

View File

@@ -147,18 +147,6 @@ void _ISR_Handler_initialization ( void );
*/
void _ISR_Handler( void );
/**
* @brief Checks if an ISR in progress.
*
* This function returns true if the processor is currently servicing
* and interrupt and false otherwise. A return value of true indicates
* that the caller is an interrupt service routine, NOT a thread.
*
* @retval true Returns true when called from an ISR.
* @retval false Returns false when not called from an ISR.
*/
bool _ISR_Is_in_progress( void );
#ifdef __cplusplus
}
#endif

View File

@@ -144,6 +144,17 @@ typedef uint32_t ISR_Level;
RTEMS_COMPILER_MEMORY_BARRIER(); \
} while (0)
/**
* @brief Checks if an ISR in progress.
*
* This function returns true, if the processor is currently servicing
* and interrupt, and false otherwise. A return value of true indicates
* that the caller is an interrupt service routine, **not** a thread.
*
* @return true Returns true, if called from within an ISR, otherwise false.
*/
bool _ISR_Is_in_progress( void );
/** @} */
#ifdef __cplusplus

View File

@@ -683,6 +683,16 @@ static inline struct _Thread_Control *_Per_CPU_Get_executing(
return cpu->executing;
}
static inline bool _Per_CPU_Is_ISR_in_progress( const Per_CPU_Control *cpu )
{
#if CPU_PROVIDES_ISR_IS_IN_PROGRESS == TRUE
(void) cpu;
return _ISR_Is_in_progress();
#else
return cpu->isr_nest_level != 0;
#endif
}
static inline bool _Per_CPU_Is_processor_online(
const Per_CPU_Control *cpu
)

View File

@@ -538,7 +538,7 @@ Status_Control _Thread_Restart(
if (
the_thread == _Per_CPU_Get_executing( cpu_self ) &&
!_ISR_Is_in_progress()
!_Per_CPU_Is_ISR_in_progress( cpu_self )
) {
ignored_life_states = THREAD_LIFE_PROTECTED | THREAD_LIFE_CHANGE_DEFERRED;
} else {