Changeset 7770cc8 for libcfa/src/concurrency/kernel_private.hfa
- Timestamp:
- Nov 24, 2021, 9:47:56 PM (4 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel_private.hfa
r94647b0b r7770cc8 39 39 } 40 40 41 // #define IO_URING_IDLE 42 41 43 //----------------------------------------------------------------------------- 42 44 // Scheduler … … 149 151 __atomic_store_n(ll, (bool)false, __ATOMIC_RELEASE); 150 152 } 151 152 153 154 155 153 156 154 //----------------------------------------------------------------------- … … 268 266 ready_schedule_lock(); 269 267 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 273 static 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; 282 291 } 283 292 … … 285 294 /* paranoid */ verify( ! __preemption_enabled() ); 286 295 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); 290 297 291 298 // Release the global lock, which we acquired when locking
Note:
See TracChangeset
for help on using the changeset viewer.