17 #ifndef _RTEMS_SCORE_SMPLOCKMCS_H 18 #define _RTEMS_SCORE_SMPLOCKMCS_H 20 #include <rtems/score/cpuopts.h> 22 #if defined(RTEMS_SMP) 68 #if defined(RTEMS_PROFILING) 69 SMP_lock_Stats_context Stats_context;
71 unsigned int queue_length;
104 #define SMP_MCS_LOCK_INITIALIZER { { ATOMIC_INITIALIZER_UINTPTR( 0 ) } } 140 #
if defined(RTEMS_PROFILING)
142 SMP_lock_Stats *stats
147 #if defined(RTEMS_PROFILING) 148 SMP_lock_Stats_acquire_context acquire_context;
150 _SMP_lock_Stats_acquire_begin( &acquire_context );
151 context->queue_length = 0;
154 _Atomic_Store_uintptr( &context->next.atomic, 0, ATOMIC_ORDER_RELAXED );
155 _Atomic_Store_uint( &context->locked, 1, ATOMIC_ORDER_RELAXED );
163 if ( previous != NULL ) {
166 _Atomic_Store_uintptr(
173 locked = _Atomic_Load_uint( &context->locked, ATOMIC_ORDER_ACQUIRE );
177 #if defined(RTEMS_PROFILING) 178 _SMP_lock_Stats_acquire_end(
181 &context->Stats_context,
182 context->queue_length
198 #if defined(RTEMS_PROFILING) 199 #define _SMP_MCS_lock_Acquire( lock, context, stats ) \ 200 _SMP_MCS_lock_Do_acquire( lock, context, stats ) 202 #define _SMP_MCS_lock_Acquire( lock, context, stats ) \ 203 _SMP_MCS_lock_Do_acquire( lock, context ) 224 if (
next == NULL ) {
228 expected = (uintptr_t) context;
229 success = _Atomic_Compare_exchange_uintptr(
233 ATOMIC_ORDER_RELEASE,
238 #if defined(RTEMS_PROFILING) 239 _SMP_lock_Stats_release_update( &context->Stats_context );
250 }
while (
next == NULL );
253 #if defined(RTEMS_PROFILING) 254 next->queue_length = context->queue_length + 1;
255 _SMP_lock_Stats_release_update( &context->Stats_context );
258 _Atomic_Store_uint( &
next->locked, 0, ATOMIC_ORDER_RELEASE );
union SMP_MCS_lock_Context::@23 next
The next context on the queue if it exists.
SMP Mellor-Crummey and Scott (MCS) lock control.
static void _SMP_MCS_lock_Do_acquire(SMP_MCS_lock_Control *lock, SMP_MCS_lock_Context *context)
Acquires the SMP MCS lock.
SMP Mellor-Crummey and Scott (MCS) lock context.
struct SMP_MCS_lock_Context SMP_MCS_lock_Context
SMP Mellor-Crummey and Scott (MCS) lock context.
static void _SMP_MCS_lock_Release(SMP_MCS_lock_Control *lock, SMP_MCS_lock_Context *context)
Releases an SMP MCS lock.
Atomic_Uint locked
Indicates if the lock is owned or free in case a previous context exits on the queue.
Atomic_Uintptr atomic
The next context as an atomic unsigned integer pointer value.
static void _SMP_MCS_lock_Initialize(SMP_MCS_lock_Control *lock)
Initializes the SMP MCS lock.
Atomic_Uintptr atomic
The queue tail context as an atomic unsigned integer pointer value.
union SMP_MCS_lock_Control::@24 queue
The queue tail context.
struct SMP_MCS_lock_Context * normal
The next context as a normal pointer.
static void _SMP_MCS_lock_Destroy(SMP_MCS_lock_Control *lock)
Destroys the SMP MCS lock.
struct SMP_MCS_lock_Context * normal
The queue tail context as a normal pointer.