From 21e2b2b9bec211f2b2c00ea6496366f5ad985b7e Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 6 Jul 2000 19:32:00 +0000 Subject: Reimplemented _Core_MUTEX_Seize to return with interrupts disabled if the mutex is successfully obtained. --- c/src/exec/score/include/rtems/score/coremutex.h | 36 +++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'c/src/exec/score/include') diff --git a/c/src/exec/score/include/rtems/score/coremutex.h b/c/src/exec/score/include/rtems/score/coremutex.h index 9f27ae0c1d..db3350dab2 100644 --- a/c/src/exec/score/include/rtems/score/coremutex.h +++ b/c/src/exec/score/include/rtems/score/coremutex.h @@ -149,15 +149,41 @@ void _CORE_mutex_Initialize( * If a unit is available or if the wait flag is FALSE, then the routine * returns. Otherwise, the calling task is blocked until a unit becomes * available. + * + * NOTE: For performance reasons, this routine is implemented as + * a macro that uses two support routines. */ -void _CORE_mutex_Seize( +RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock( + CORE_mutex_Control *the_mutex, + ISR_Level *level_p +); + +void _CORE_mutex_Seize_interrupt_blocking( CORE_mutex_Control *the_mutex, - Objects_Id id, boolean wait, Watchdog_Interval timeout ); - + +#define _CORE_mutex_Seize( \ + _the_mutex, _id, _wait, _timeout, _level ) \ + do { \ + if ( _CORE_mutex_Seize_interrupt_trylock( _the_mutex, &_level ) ) { \ + if ( !_wait ) { \ + _ISR_Enable( _level ); \ + _Thread_Executing->Wait.return_code = \ + CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT; \ + } else { \ + _Thread_queue_Enter_critical_section( &(_the_mutex)->Wait_queue ); \ + _Thread_Executing->Wait.queue = &(_the_mutex)->Wait_queue; \ + _Thread_Executing->Wait.id = _id; \ + _Thread_Disable_dispatch(); \ + _ISR_Enable( _level ); \ + _CORE_mutex_Seize_interrupt_blocking( _the_mutex, _id, _timeout ); \ + } \ + } \ + } while (0) + /* * _CORE_mutex_Surrender * @@ -189,10 +215,6 @@ void _CORE_mutex_Flush( unsigned32 status ); -#ifndef __RTEMS_APPLICATION__ -#include -#endif - #ifdef __cplusplus } #endif -- cgit v1.2.3