37#ifndef _RTEMS_SCORE_SMPLOCKMCS_H
38#define _RTEMS_SCORE_SMPLOCKMCS_H
40#include <rtems/score/cpuopts.h>
60typedef struct SMP_MCS_lock_Context {
68 Atomic_Uintptr atomic;
75 struct SMP_MCS_lock_Context *normal;
88#if defined(RTEMS_PROFILING)
89 SMP_lock_Stats_context Stats_context;
91 unsigned int queue_length;
93} SMP_MCS_lock_Context;
110 Atomic_Uintptr atomic;
117 struct SMP_MCS_lock_Context *normal;
119} SMP_MCS_lock_Control;
124#define SMP_MCS_LOCK_INITIALIZER { { ATOMIC_INITIALIZER_UINTPTR( 0 ) } }
133static inline void _SMP_MCS_lock_Initialize( SMP_MCS_lock_Control *lock )
135 _Atomic_Init_uintptr( &lock->queue.atomic, 0 );
145static inline void _SMP_MCS_lock_Destroy( SMP_MCS_lock_Control *lock )
157static inline void _SMP_MCS_lock_Do_acquire(
158 SMP_MCS_lock_Control *lock,
160#
if defined(RTEMS_PROFILING)
162 SMP_lock_Stats *stats
166 SMP_MCS_lock_Context *previous;
167#if defined(RTEMS_PROFILING)
168 SMP_lock_Stats_acquire_context acquire_context;
170 _SMP_lock_Stats_acquire_begin( &acquire_context );
174 _Atomic_Store_uintptr( &
context->next.atomic, 0, ATOMIC_ORDER_RELAXED );
175 _Atomic_Store_uint( &
context->locked, 1, ATOMIC_ORDER_RELAXED );
177 previous = (SMP_MCS_lock_Context *) _Atomic_Exchange_uintptr(
183 if ( previous !=
NULL ) {
186 _Atomic_Store_uintptr(
187 &previous->next.atomic,
193 locked = _Atomic_Load_uint( &
context->locked, ATOMIC_ORDER_ACQUIRE );
194 }
while ( locked != 0 );
197#if defined(RTEMS_PROFILING)
198 _SMP_lock_Stats_acquire_end(
218#if defined(RTEMS_PROFILING)
219 #define _SMP_MCS_lock_Acquire( lock, context, stats ) \
220 _SMP_MCS_lock_Do_acquire( lock, context, stats )
222 #define _SMP_MCS_lock_Acquire( lock, context, stats ) \
223 _SMP_MCS_lock_Do_acquire( lock, context )
232static inline void _SMP_MCS_lock_Release(
233 SMP_MCS_lock_Control *lock,
237 SMP_MCS_lock_Context *next;
239 next = (SMP_MCS_lock_Context *) _Atomic_Load_uintptr(
244 if ( next ==
NULL ) {
248 expected = (uintptr_t)
context;
249 success = _Atomic_Compare_exchange_uintptr(
253 ATOMIC_ORDER_RELEASE,
258#if defined(RTEMS_PROFILING)
259 _SMP_lock_Stats_release_update( &
context->Stats_context );
266 next = (SMP_MCS_lock_Context *) _Atomic_Load_uintptr(
270 }
while ( next ==
NULL );
273#if defined(RTEMS_PROFILING)
274 next->queue_length =
context->queue_length + 1;
275 _SMP_lock_Stats_release_update( &
context->Stats_context );
278 _Atomic_Store_uint( &next->locked, 0, ATOMIC_ORDER_RELEASE );
#define NULL
Requests a GPIO pin group configuration.
Definition: xil_types.h:54
This header file provides the interfaces of the Atomic Operations.
rtems_termios_device_context * context
Definition: console-config.c:62
This header file provides the interfaces of the SMP Locks related to lock statistics.