summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-12 09:25:39 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-14 16:26:06 +0200
commit49cdf40afa1b67b1eedbec26b73c59f54dc882cd (patch)
treed5f27895d8bb30533150c66fd019a18291a52e6a /cpukit/score
parentscore: Add _Chain_Insert_ordered_unprotected() (diff)
downloadrtems-49cdf40afa1b67b1eedbec26b73c59f54dc882cd.tar.bz2
score: Add and use _Thread_Dispatch_is_enabled()
Delete _Thread_Dispatch_in_critical_section() and _Thread_Is_dispatching_enabled().
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/cpu/lm32/irq.c2
-rw-r--r--cpukit/score/cpu/nios2/nios2-iic-irq.c2
-rw-r--r--cpukit/score/include/rtems/score/coremutex.h2
-rw-r--r--cpukit/score/include/rtems/score/threaddispatch.h45
-rw-r--r--cpukit/score/src/heapfree.c2
-rw-r--r--cpukit/score/src/pheapwalk.c2
-rw-r--r--cpukit/score/src/threaddispatchdisablelevel.c8
7 files changed, 18 insertions, 45 deletions
diff --git a/cpukit/score/cpu/lm32/irq.c b/cpukit/score/cpu/lm32/irq.c
index 37e9a28f53..b69a65dd67 100644
--- a/cpukit/score/cpu/lm32/irq.c
+++ b/cpukit/score/cpu/lm32/irq.c
@@ -72,7 +72,7 @@ void __ISR_Handler(uint32_t vector, CPU_Interrupt_frame *ifr)
if ( _ISR_Nest_level )
return;
- if ( _Thread_Dispatch_necessary && !_Thread_Dispatch_in_critical_section() ) {
+ if ( _Thread_Dispatch_necessary && _Thread_Dispatch_is_enabled() ) {
/* save off our stack frame so the context switcher can get to it */
_exception_stack_frame = ifr;
diff --git a/cpukit/score/cpu/nios2/nios2-iic-irq.c b/cpukit/score/cpu/nios2/nios2-iic-irq.c
index 31e2ba9ad8..1f29365327 100644
--- a/cpukit/score/cpu/nios2/nios2-iic-irq.c
+++ b/cpukit/score/cpu/nios2/nios2-iic-irq.c
@@ -117,7 +117,7 @@ void __ISR_Handler(void)
stack_ptr = _old_stack_ptr;
#endif
- if( !_Thread_Dispatch_in_critical_section() )
+ if( _Thread_Dispatch_is_enabled() )
{
if ( _Thread_Dispatch_necessary ) {
_CPU_ISR_Enable( level );
diff --git a/cpukit/score/include/rtems/score/coremutex.h b/cpukit/score/include/rtems/score/coremutex.h
index 10dfe06fa2..f6c377c2a0 100644
--- a/cpukit/score/include/rtems/score/coremutex.h
+++ b/cpukit/score/include/rtems/score/coremutex.h
@@ -352,7 +352,7 @@ void _CORE_mutex_Seize_interrupt_blocking(
#define _CORE_mutex_Check_dispatch_for_seize(_wait) 0
#else
#define _CORE_mutex_Check_dispatch_for_seize(_wait) \
- (_Thread_Dispatch_in_critical_section() \
+ (!_Thread_Dispatch_is_enabled() \
&& (_wait) \
&& (_System_state_Get() >= SYSTEM_STATE_BEGIN_MULTITASKING))
#endif
diff --git a/cpukit/score/include/rtems/score/threaddispatch.h b/cpukit/score/include/rtems/score/threaddispatch.h
index 0333e9b66f..e3065da590 100644
--- a/cpukit/score/include/rtems/score/threaddispatch.h
+++ b/cpukit/score/include/rtems/score/threaddispatch.h
@@ -46,6 +46,19 @@ extern "C" {
*/
SCORE_EXTERN volatile uint32_t _Thread_Dispatch_disable_level;
+/**
+ * @brief Indicates if the executing thread is inside a thread dispatch
+ * critical section.
+ *
+ * @retval true Thread dispatching is enabled.
+ * @retval false The executing thread is inside a thread dispatch critical
+ * section and dispatching is not allowed.
+ */
+RTEMS_INLINE_ROUTINE bool _Thread_Dispatch_is_enabled(void)
+{
+ return _Thread_Dispatch_disable_level == 0;
+}
+
#if defined(RTEMS_SMP)
typedef struct {
SMP_lock_Control lock;
@@ -68,14 +81,6 @@ SCORE_EXTERN volatile uint32_t _Thread_Dispatch_disable_level;
void _Thread_Dispatch_initialization(void);
/**
- * @brief Checks if thread dispatch says that we are in a critical section.
- *
- * This routine returns true if thread dispatch indicates
- * that we are in a critical section.
- */
- bool _Thread_Dispatch_in_critical_section(void);
-
- /**
* @brief Returns value of the the thread dispatch level.
*
* This routine returns value of the the thread dispatch level.
@@ -105,20 +110,6 @@ SCORE_EXTERN volatile uint32_t _Thread_Dispatch_disable_level;
uint32_t _Thread_Dispatch_decrement_disable_level(void);
#else /* RTEMS_SMP */
/**
- * @brief _Thread_Dispatch_in_critical_section
- *
- * This routine returns true if thread dispatch indicates
- * that we are in a critical section.
- */
- RTEMS_INLINE_ROUTINE bool _Thread_Dispatch_in_critical_section(void)
- {
- if ( _Thread_Dispatch_disable_level == 0 )
- return false;
-
- return true;
- }
-
- /**
* @brief Get thread dispatch disable level.
*
* This routine returns value of the the thread dispatch level.
@@ -246,16 +237,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Unnest_dispatch( void )
_Thread_Dispatch_decrement_disable_level();
}
-/**
- * This function returns true if dispatching is disabled, and false
- * otherwise.
- */
-
-RTEMS_INLINE_ROUTINE bool _Thread_Is_dispatching_enabled( void )
-{
- return ( _Thread_Dispatch_in_critical_section() == false );
-}
-
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/score/src/heapfree.c b/cpukit/score/src/heapfree.c
index d53a54de77..30a84a08b4 100644
--- a/cpukit/score/src/heapfree.c
+++ b/cpukit/score/src/heapfree.c
@@ -87,7 +87,7 @@
* is the task stack of a thread that deletes itself. The thread dispatch
* disable level is a way to detect this use case.
*/
- if ( !_Thread_Dispatch_in_critical_section() ) {
+ if ( _Thread_Dispatch_is_enabled() ) {
Heap_Block *const next = block->Protection_begin.next_delayed_free_block;
if ( next == NULL ) {
_Heap_Protection_delay_block_free( heap, block );
diff --git a/cpukit/score/src/pheapwalk.c b/cpukit/score/src/pheapwalk.c
index 12b2a6d2a8..d06d8bca67 100644
--- a/cpukit/score/src/pheapwalk.c
+++ b/cpukit/score/src/pheapwalk.c
@@ -37,7 +37,7 @@ bool _Protected_heap_Walk(
*
* NOTE: Dispatching is also disabled during initialization.
*/
- if ( _Thread_Dispatch_in_critical_section() == false ) {
+ if ( _Thread_Dispatch_is_enabled() ) {
_RTEMS_Lock_allocator();
status = _Heap_Walk( the_heap, source, do_dump );
_RTEMS_Unlock_allocator();
diff --git a/cpukit/score/src/threaddispatchdisablelevel.c b/cpukit/score/src/threaddispatchdisablelevel.c
index 154a6af637..1f84bfe65c 100644
--- a/cpukit/score/src/threaddispatchdisablelevel.c
+++ b/cpukit/score/src/threaddispatchdisablelevel.c
@@ -39,14 +39,6 @@ void _Thread_Dispatch_initialization( void )
_Thread_Dispatch_set_disable_level( 1 );
}
-bool _Thread_Dispatch_in_critical_section(void)
-{
- if ( _Thread_Dispatch_disable_level == 0 )
- return false;
-
- return true;
-}
-
uint32_t _Thread_Dispatch_get_disable_level(void)
{
return _Thread_Dispatch_disable_level;