Changeset 34b8cb7
- Timestamp:
- Nov 19, 2021, 11:23:17 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- b14ec5f
- Parents:
- 3df86cc
- Location:
- libcfa/src/concurrency
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
r3df86cc r34b8cb7 126 126 static void mark_idle (__cluster_proc_list & idles, processor & proc); 127 127 static void mark_awake(__cluster_proc_list & idles, processor & proc); 128 static [unsigned idle, unsigned total, * processor] query_idles( & __cluster_proc_list idles );129 128 130 129 extern void __cfa_io_start( processor * ); … … 766 765 767 766 // Check if there is a sleeping processor 768 processor * p; 769 unsigned idle; 770 unsigned total; 771 [idle, total, p] = query_idles(this->procs); 767 int fd = __atomic_load_n(&this->procs.fd, __ATOMIC_SEQ_CST); 772 768 773 769 // If no one is sleeping, we are done 774 if( idle== 0 ) return;770 if( fd == 0 ) return; 775 771 776 772 // We found a processor, wake it up 777 773 eventfd_t val; 778 774 val = 1; 779 eventfd_write( p->idle, val );775 eventfd_write( fd, val ); 780 776 781 777 #if !defined(__CFA_NO_STATISTICS__) … … 813 809 remove(proc); 814 810 insert_first(this.idles, proc); 811 812 __atomic_store_n(&this.fd, proc.idle, __ATOMIC_SEQ_CST); 815 813 unlock( this ); 816 814 /* paranoid */ verify( ! __preemption_enabled() ); … … 824 822 remove(proc); 825 823 insert_last(this.actives, proc); 824 825 __atomic_store_n(&this.fd, this.idles`first.idle, __ATOMIC_SEQ_CST); 826 826 unlock( this ); 827 /* paranoid */ verify( ! __preemption_enabled() );828 }829 830 static [unsigned idle, unsigned total, * processor] query_idles( & __cluster_proc_list this ) {831 /* paranoid */ verify( ! __preemption_enabled() );832 /* paranoid */ verify( ready_schedule_islocked() );833 834 for() {835 uint64_t l = __atomic_load_n(&this.lock, __ATOMIC_SEQ_CST);836 if( 1 == (l % 2) ) { Pause(); continue; }837 unsigned idle = this.idle;838 unsigned total = this.total;839 processor * proc = &this.idles`first;840 // Compiler fence is unnecessary, but gcc-8 and older incorrectly reorder code without it841 asm volatile("": : :"memory");842 if(l != __atomic_load_n(&this.lock, __ATOMIC_SEQ_CST)) { Pause(); continue; }843 return [idle, total, proc];844 }845 846 /* paranoid */ verify( ready_schedule_islocked() );847 827 /* paranoid */ verify( ! __preemption_enabled() ); 848 828 } … … 906 886 if(head == tail) return false; 907 887 #if OLD_MAIN 908 ready_schedule_lock();909 ret = __cfa_io_drain( proc );910 ready_schedule_unlock();888 ready_schedule_lock(); 889 ret = __cfa_io_drain( proc ); 890 ready_schedule_unlock(); 911 891 #else 912 892 ret = __cfa_io_drain( proc ); 913 #endif893 #endif 914 894 #endif 915 895 return ret; -
libcfa/src/concurrency/kernel.hfa
r3df86cc r34b8cb7 195 195 struct __cluster_proc_list { 196 196 // Spin lock protecting the queue 197 volatile uint64_t lock; 197 __spinlock_t lock; 198 199 // FD to use to wake a processor 200 volatile int fd; 198 201 199 202 // Total number of processors -
libcfa/src/concurrency/kernel/startup.cfa
r3df86cc r34b8cb7 584 584 // Cluster 585 585 static void ?{}(__cluster_proc_list & this) { 586 this. lock= 0;586 this.fd = 0; 587 587 this.idle = 0; 588 588 this.total = 0;
Note: See TracChangeset
for help on using the changeset viewer.