Keep interrupts disabled during the thread lock acquire sequence. --- cpukit/score/include/rtems/score/threadimpl.h | 31 +++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index 448f38d..182cb3a 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -1105,14 +1105,14 @@ RTEMS_INLINE_ROUTINE void _Thread_Lock_release_default( } /** - * @brief Acquires the thread lock. + * @brief Acquires the thread lock inside a critical section (interrupts disabled). * * @param[in] the_thread The thread. - * @param[in] lock_context The lock context for _Thread_Lock_release(). + * @param[in] lock_context The lock context for _Thread_Lock_release_critical(). * - * @return The lock required by _Thread_Lock_release(). + * @return The lock required by _Thread_Lock_release_critical(). */ -RTEMS_INLINE_ROUTINE void *_Thread_Lock_acquire( +RTEMS_INLINE_ROUTINE void *_Thread_Lock_acquire_critical( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -1123,8 +1123,6 @@ RTEMS_INLINE_ROUTINE void *_Thread_Lock_acquire( while ( true ) { SMP_ticket_lock_Control *lock_1; - _ISR_lock_ISR_disable( lock_context ); - /* * We assume that a normal load of pointer is identical to a relaxed atomic * load. Here, we may read an out-of-date lock. However, only the owner @@ -1168,15 +1166,30 @@ RTEMS_INLINE_ROUTINE void *_Thread_Lock_acquire( return lock_0; } - _Thread_Lock_release( lock_0, lock_context ); + _Thread_Lock_release_critical( lock_0, lock_context ); } #else - _ISR_Local_disable( lock_context->isr_level ); - return NULL; #endif } +/** + * @brief Acquires the thread lock. + * + * @param[in] the_thread The thread. + * @param[in] lock_context The lock context for _Thread_Lock_release(). + * + * @return The lock required by _Thread_Lock_release(). + */ +RTEMS_INLINE_ROUTINE void *_Thread_Lock_acquire( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_ISR_disable( lock_context ); + return _Thread_Lock_acquire_critical( the_thread, lock_context ); +} + #if defined(RTEMS_SMP) /* * Internal function, use _Thread_Lock_set() or _Thread_Lock_restore_default() -- 1.8.4.5 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel