Ignore:
Timestamp:
Nov 19, 2021, 11:23:24 AM (9 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
enum, forall-pointer-decay, master, pthread-emulation
Children:
a633f6f
Parents:
34b8cb7 (diff), 84a6e70 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r34b8cb7 rb14ec5f  
    282282}
    283283
     284static inline bool try_lock(__cluster_proc_list & this) {
     285        /* paranoid */ verify( ! __preemption_enabled() );
     286
     287        // Start by locking the global RWlock so that we know no-one is
     288        // adding/removing processors while we mess with the idle lock
     289        ready_schedule_lock();
     290
     291        // Simple counting lock, acquired, acquired by incrementing the counter
     292        // to an odd number
     293        uint64_t l = this.lock;
     294        if(
     295                (0 == (l % 2))
     296                && __atomic_compare_exchange_n(&this.lock, &l, l + 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
     297        ) {
     298                // success
     299                /* paranoid */ verify( ! __preemption_enabled() );
     300                return true;
     301        }
     302
     303        // failed to lock
     304        ready_schedule_unlock();
     305
     306        /* paranoid */ verify( ! __preemption_enabled() );
     307        return false;
     308}
     309
    284310static inline void unlock(__cluster_proc_list & this) {
    285311        /* paranoid */ verify( ! __preemption_enabled() );
Note: See TracChangeset for help on using the changeset viewer.