Ignore:
File:
1 edited

Legend:

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

    rd3605f8 r24e321c  
    3939}
    4040
    41 // Defines whether or not we *want* to use io_uring_enter as the idle_sleep blocking call
    42 #define CFA_WANT_IO_URING_IDLE
    43 
    44 // Defines whether or not we *can* use io_uring_enter as the idle_sleep blocking call
    45 #if defined(CFA_WANT_IO_URING_IDLE) && defined(CFA_HAVE_LINUX_IO_URING_H)
    46         #if defined(CFA_HAVE_IORING_OP_READ) || (defined(CFA_HAVE_READV) && defined(CFA_HAVE_IORING_OP_READV))
    47                 #define CFA_WITH_IO_URING_IDLE
    48         #endif
    49 #endif
    50 
    5141//-----------------------------------------------------------------------------
    5242// Scheduler
     
    159149        __atomic_store_n(ll, (bool)false, __ATOMIC_RELEASE);
    160150}
     151
     152
     153
     154
    161155
    162156//-----------------------------------------------------------------------
     
    274268        ready_schedule_lock();
    275269
    276         lock( this.lock __cfaabi_dbg_ctx2 );
    277 
    278         /* paranoid */ verify( ! __preemption_enabled() );
    279 }
    280 
    281 static inline bool try_lock(__cluster_proc_list & this) {
    282         /* paranoid */ verify( ! __preemption_enabled() );
    283 
    284         // Start by locking the global RWlock so that we know no-one is
    285         // adding/removing processors while we mess with the idle lock
    286         ready_schedule_lock();
    287 
    288         if(try_lock( this.lock __cfaabi_dbg_ctx2 )) {
    289                 // success
    290                 /* paranoid */ verify( ! __preemption_enabled() );
    291                 return true;
    292         }
    293 
    294         // failed to lock
    295         ready_schedule_unlock();
    296 
    297         /* paranoid */ verify( ! __preemption_enabled() );
    298         return false;
     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() );
    299282}
    300283
     
    302285        /* paranoid */ verify( ! __preemption_enabled() );
    303286
    304         unlock(this.lock);
     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 );
    305290
    306291        // Release the global lock, which we acquired when locking
Note: See TracChangeset for help on using the changeset viewer.