Changeset a5294af for libcfa/src/concurrency/locks.hfa
- Timestamp:
- May 25, 2023, 5:00:06 PM (17 months ago)
- Branches:
- ast-experimental, master
- Children:
- a5aa5bf
- Parents:
- 4246869 (diff), bccd70a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/locks.hfa
r4246869 ra5294af 176 176 static inline void ?{}(mcs_spin_node & this) { this.next = 0p; this.locked = true; } 177 177 178 static inline mcs_spin_node * volatile & ?`next ( mcs_spin_node * node ) {179 return node->next;180 }181 182 178 struct mcs_spin_lock { 183 179 mcs_spin_queue queue; … … 185 181 186 182 static inline void lock(mcs_spin_lock & l, mcs_spin_node & n) { 183 n.locked = true; 187 184 mcs_spin_node * prev = __atomic_exchange_n(&l.queue.tail, &n, __ATOMIC_SEQ_CST); 188 n.locked = true; 189 if(prev == 0p) return; 185 if( prev == 0p ) return; 190 186 prev->next = &n; 191 while( __atomic_load_n(&n.locked, __ATOMIC_RELAXED)) Pause();187 while( __atomic_load_n(&n.locked, __ATOMIC_RELAXED) ) Pause(); 192 188 } 193 189 … … 195 191 mcs_spin_node * n_ptr = &n; 196 192 if (__atomic_compare_exchange_n(&l.queue.tail, &n_ptr, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) return; 197 while (__atomic_load_n(&n.next, __ATOMIC_RELAXED) == 0p) {}193 while (__atomic_load_n(&n.next, __ATOMIC_RELAXED) == 0p) Pause(); 198 194 n.next->locked = false; 199 195 }
Note: See TracChangeset
for help on using the changeset viewer.