Ignore:
Timestamp:
Nov 24, 2021, 9:47:56 PM (4 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
5235d49
Parents:
94647b0b (diff), 3cc1111 (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

    r94647b0b r7770cc8  
    3939}
    4040
     41// #define IO_URING_IDLE
     42
    4143//-----------------------------------------------------------------------------
    4244// Scheduler
     
    149151        __atomic_store_n(ll, (bool)false, __ATOMIC_RELEASE);
    150152}
    151 
    152 
    153 
    154 
    155153
    156154//-----------------------------------------------------------------------
     
    268266        ready_schedule_lock();
    269267
    270         // Simple counting lock, acquired, acquired by incrementing the counter
    271         // to an odd number
    272         for() {
    273                 uint64_t l = this.lock;
    274                 if(
    275                         (0 == (l % 2))
    276                         && __atomic_compare_exchange_n(&this.lock, &l, l + 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
    277                 ) return;
    278                 Pause();
    279         }
    280 
    281         /* paranoid */ verify( ! __preemption_enabled() );
     268        lock( this.lock __cfaabi_dbg_ctx2 );
     269
     270        /* paranoid */ verify( ! __preemption_enabled() );
     271}
     272
     273static inline bool try_lock(__cluster_proc_list & this) {
     274        /* paranoid */ verify( ! __preemption_enabled() );
     275
     276        // Start by locking the global RWlock so that we know no-one is
     277        // adding/removing processors while we mess with the idle lock
     278        ready_schedule_lock();
     279
     280        if(try_lock( this.lock __cfaabi_dbg_ctx2 )) {
     281                // success
     282                /* paranoid */ verify( ! __preemption_enabled() );
     283                return true;
     284        }
     285
     286        // failed to lock
     287        ready_schedule_unlock();
     288
     289        /* paranoid */ verify( ! __preemption_enabled() );
     290        return false;
    282291}
    283292
     
    285294        /* paranoid */ verify( ! __preemption_enabled() );
    286295
    287         /* paranoid */ verify( 1 == (this.lock % 2) );
    288         // Simple couting lock, release by incrementing to an even number
    289         __atomic_fetch_add( &this.lock, 1, __ATOMIC_SEQ_CST );
     296        unlock(this.lock);
    290297
    291298        // Release the global lock, which we acquired when locking
Note: See TracChangeset for help on using the changeset viewer.