- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel.cfa (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
rec43cf9 r431cd4f 113 113 static void __wake_one(cluster * cltr); 114 114 115 static void push (__cluster_idles& idles, processor & proc);116 static void remove(__cluster_idles& idles, processor & proc);117 static [unsigned idle, unsigned total, * processor] query ( & __cluster_idlesidles );115 static void mark_idle (__cluster_proc_list & idles, processor & proc); 116 static void mark_awake(__cluster_proc_list & idles, processor & proc); 117 static [unsigned idle, unsigned total, * processor] query_idles( & __cluster_proc_list idles ); 118 118 119 119 extern void __cfa_io_start( processor * ); … … 189 189 190 190 // Push self to idle stack 191 push(this->cltr->idles, * this);191 mark_idle(this->cltr->procs, * this); 192 192 193 193 // Confirm the ready-queue is empty … … 195 195 if( readyThread ) { 196 196 // A thread was found, cancel the halt 197 remove(this->cltr->idles, * this);197 mark_awake(this->cltr->procs, * this); 198 198 199 199 #if !defined(__CFA_NO_STATISTICS__) … … 225 225 226 226 // We were woken up, remove self from idle 227 remove(this->cltr->idles, * this);227 mark_awake(this->cltr->procs, * this); 228 228 229 229 // DON'T just proceed, start looking again … … 359 359 #if !defined(__CFA_NO_STATISTICS__) 360 360 __tls_stats()->ready.threads.threads++; 361 __push_stat( __tls_stats(), __tls_stats()->ready.threads.threads, false, "Processor", this ); 361 362 #endif 362 363 // This is case 2, the racy case, someone tried to run this thread before it finished blocking … … 376 377 #if !defined(__CFA_NO_STATISTICS__) 377 378 __tls_stats()->ready.threads.threads--; 379 __push_stat( __tls_stats(), __tls_stats()->ready.threads.threads, false, "Processor", this ); 378 380 #endif 379 381 … … 455 457 if( kernelTLS().this_stats ) { 456 458 __tls_stats()->ready.threads.threads++; 459 __push_stat( __tls_stats(), __tls_stats()->ready.threads.threads, false, "Processor", kernelTLS().this_processor ); 457 460 } 458 461 else { 459 462 __atomic_fetch_add(&cl->stats->ready.threads.threads, 1, __ATOMIC_RELAXED); 463 __push_stat( cl->stats, cl->stats->ready.threads.threads, true, "Cluster", cl ); 460 464 } 461 465 #endif … … 470 474 471 475 ready_schedule_lock(); 472 $thread * thrd = pop ( this );476 $thread * thrd = pop_fast( this ); 473 477 ready_schedule_unlock(); 474 478 … … 613 617 unsigned idle; 614 618 unsigned total; 615 [idle, total, p] = query (this->idles);619 [idle, total, p] = query_idles(this->procs); 616 620 617 621 // If no one is sleeping, we are done … … 650 654 } 651 655 652 static void push (__cluster_idles& this, processor & proc) {656 static void mark_idle(__cluster_proc_list & this, processor & proc) { 653 657 /* paranoid */ verify( ! __preemption_enabled() ); 654 658 lock( this ); 655 659 this.idle++; 656 660 /* paranoid */ verify( this.idle <= this.total ); 657 658 insert_first(this. list, proc);661 remove(proc); 662 insert_first(this.idles, proc); 659 663 unlock( this ); 660 664 /* paranoid */ verify( ! __preemption_enabled() ); 661 665 } 662 666 663 static void remove(__cluster_idles& this, processor & proc) {667 static void mark_awake(__cluster_proc_list & this, processor & proc) { 664 668 /* paranoid */ verify( ! __preemption_enabled() ); 665 669 lock( this ); 666 670 this.idle--; 667 671 /* paranoid */ verify( this.idle >= 0 ); 668 669 672 remove(proc); 673 insert_last(this.actives, proc); 670 674 unlock( this ); 671 675 /* paranoid */ verify( ! __preemption_enabled() ); 672 676 } 673 677 674 static [unsigned idle, unsigned total, * processor] query( & __cluster_idles this ) { 678 static [unsigned idle, unsigned total, * processor] query_idles( & __cluster_proc_list this ) { 679 /* paranoid */ verify( ! __preemption_enabled() ); 680 /* paranoid */ verify( ready_schedule_islocked() ); 681 675 682 for() { 676 683 uint64_t l = __atomic_load_n(&this.lock, __ATOMIC_SEQ_CST); … … 678 685 unsigned idle = this.idle; 679 686 unsigned total = this.total; 680 processor * proc = &this. list`first;687 processor * proc = &this.idles`first; 681 688 // Compiler fence is unnecessary, but gcc-8 and older incorrectly reorder code without it 682 689 asm volatile("": : :"memory"); … … 684 691 return [idle, total, proc]; 685 692 } 693 694 /* paranoid */ verify( ready_schedule_islocked() ); 695 /* paranoid */ verify( ! __preemption_enabled() ); 686 696 } 687 697
Note:
See TracChangeset
for help on using the changeset viewer.