Changes in / [84a6e70:3df86cc]
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
-
kernel.cfa (modified) (5 diffs)
-
kernel_private.hfa (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
r84a6e70 r3df86cc 124 124 static void __wake_one(cluster * cltr); 125 125 126 static boolmark_idle (__cluster_proc_list & idles, processor & proc);126 static void mark_idle (__cluster_proc_list & idles, processor & proc); 127 127 static void mark_awake(__cluster_proc_list & idles, processor & proc); 128 128 static [unsigned idle, unsigned total, * processor] query_idles( & __cluster_proc_list idles ); … … 213 213 214 214 // Push self to idle stack 215 if(!mark_idle(this->cltr->procs, * this)) continue MAIN_LOOP;215 mark_idle(this->cltr->procs, * this); 216 216 217 217 // Confirm the ready-queue is empty … … 331 331 // Push self to idle stack 332 332 ready_schedule_unlock(); 333 if(!mark_idle(this->cltr->procs, * this)) goto SEARCH;333 mark_idle(this->cltr->procs, * this); 334 334 ready_schedule_lock(); 335 335 … … 806 806 } 807 807 808 static boolmark_idle(__cluster_proc_list & this, processor & proc) {809 /* paranoid */ verify( ! __preemption_enabled() ); 810 if(!try_lock( this )) return false;808 static void mark_idle(__cluster_proc_list & this, processor & proc) { 809 /* paranoid */ verify( ! __preemption_enabled() ); 810 lock( this ); 811 811 this.idle++; 812 812 /* paranoid */ verify( this.idle <= this.total ); … … 815 815 unlock( this ); 816 816 /* paranoid */ verify( ! __preemption_enabled() ); 817 818 return true;819 817 } 820 818 -
libcfa/src/concurrency/kernel_private.hfa
r84a6e70 r3df86cc 282 282 } 283 283 284 static 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 is288 // adding/removing processors while we mess with the idle lock289 ready_schedule_lock();290 291 // Simple counting lock, acquired, acquired by incrementing the counter292 // to an odd number293 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 // success299 /* paranoid */ verify( ! __preemption_enabled() );300 return true;301 }302 303 // failed to lock304 ready_schedule_unlock();305 306 /* paranoid */ verify( ! __preemption_enabled() );307 return false;308 }309 310 284 static inline void unlock(__cluster_proc_list & this) { 311 285 /* paranoid */ verify( ! __preemption_enabled() );
Note:
See TracChangeset
for help on using the changeset viewer.