17 #ifndef _RTEMS_SCORE_SMPLOCKSEQ_H 18 #define _RTEMS_SCORE_SMPLOCKSEQ_H 20 #include <rtems/score/cpuopts.h> 22 #if defined(RTEMS_SMP) 24 #include <rtems/score/assert.h> 57 } SMP_sequence_lock_Control;
62 #define SMP_SEQUENCE_LOCK_INITIALIZER { ATOMIC_INITIALIZER_UINT( 0 ) } 71 static inline void _SMP_sequence_lock_Initialize( SMP_sequence_lock_Control *lock )
73 _Atomic_Init_uint( &lock->sequence, 0 );
83 static inline void _SMP_sequence_lock_Destroy( SMP_sequence_lock_Control *lock )
99 static inline unsigned int _SMP_sequence_lock_Write_begin(
100 SMP_sequence_lock_Control *lock
105 seq = _Atomic_Load_uint( &lock->sequence, ATOMIC_ORDER_RELAXED );
106 _Assert( seq % 2 == 0 );
108 _Atomic_Store_uint( &lock->sequence, seq + 1, ATOMIC_ORDER_RELAXED );
111 _Atomic_Fence( ATOMIC_ORDER_ACQ_REL );
122 static inline void _SMP_sequence_lock_Write_end(
123 SMP_sequence_lock_Control *lock,
127 _Atomic_Store_uint( &lock->sequence, seq + 2, ATOMIC_ORDER_RELEASE );
139 static inline unsigned int _SMP_sequence_lock_Read_begin(
140 const SMP_sequence_lock_Control *lock
143 return _Atomic_Load_uint( &lock->sequence, ATOMIC_ORDER_ACQUIRE );
157 static inline bool _SMP_sequence_lock_Read_retry(
158 SMP_sequence_lock_Control *lock,
164 seq2 = _Atomic_Fetch_add_uint( &lock->sequence, 0, ATOMIC_ORDER_RELEASE );
165 return seq != seq2 || seq % 2 != 0;