Changeset 76a798d


Ignore:
Timestamp:
Jun 16, 2022, 2:47:50 PM (2 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
9e23b446, df932552
Parents:
9e3d123
Message:

hopefully fixed mcs spin lock

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/locks.hfa

    r9e3d123 r76a798d  
    126126static inline void lock(mcs_spin_lock & l, mcs_spin_node & n) {
    127127        mcs_spin_node * prev = __atomic_exchange_n(&l.queue.tail, &n, __ATOMIC_SEQ_CST);
     128        n.locked = true;
    128129        if(prev == 0p) return;
    129130        prev->next = &n;
    130         while(__atomic_load_n(&n.locked, __ATOMIC_SEQ_CST)) Pause();
     131        while(__atomic_load_n(&n.locked, __ATOMIC_RELAXED)) Pause();
    131132}
    132133
     
    134135        mcs_spin_node * n_ptr = &n;
    135136        if (__atomic_compare_exchange_n(&l.queue.tail, &n_ptr, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) return;
    136         while (__atomic_load_n(&n.next, __ATOMIC_SEQ_CST) == 0p) {}
     137        while (__atomic_load_n(&n.next, __ATOMIC_RELAXED) == 0p) {}
    137138        n.next->locked = false;
    138139}
Note: See TracChangeset for help on using the changeset viewer.