Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.cfa

    r431cd4f rec43cf9  
    113113static void __wake_one(cluster * cltr);
    114114
    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 );
     115static void push  (__cluster_idles & idles, processor & proc);
     116static void remove(__cluster_idles & idles, processor & proc);
     117static [unsigned idle, unsigned total, * processor] query( & __cluster_idles idles );
    118118
    119119extern void __cfa_io_start( processor * );
     
    189189
    190190                                // Push self to idle stack
    191                                 mark_idle(this->cltr->procs, * this);
     191                                push(this->cltr->idles, * this);
    192192
    193193                                // Confirm the ready-queue is empty
     
    195195                                if( readyThread ) {
    196196                                        // A thread was found, cancel the halt
    197                                         mark_awake(this->cltr->procs, * this);
     197                                        remove(this->cltr->idles, * this);
    198198
    199199                                        #if !defined(__CFA_NO_STATISTICS__)
     
    225225
    226226                                // We were woken up, remove self from idle
    227                                 mark_awake(this->cltr->procs, * this);
     227                                remove(this->cltr->idles, * this);
    228228
    229229                                // DON'T just proceed, start looking again
     
    359359                                #if !defined(__CFA_NO_STATISTICS__)
    360360                                        __tls_stats()->ready.threads.threads++;
    361                                         __push_stat( __tls_stats(), __tls_stats()->ready.threads.threads, false, "Processor", this );
    362361                                #endif
    363362                                // This is case 2, the racy case, someone tried to run this thread before it finished blocking
     
    377376        #if !defined(__CFA_NO_STATISTICS__)
    378377                __tls_stats()->ready.threads.threads--;
    379                 __push_stat( __tls_stats(), __tls_stats()->ready.threads.threads, false, "Processor", this );
    380378        #endif
    381379
     
    457455                if( kernelTLS().this_stats ) {
    458456                        __tls_stats()->ready.threads.threads++;
    459                         __push_stat( __tls_stats(), __tls_stats()->ready.threads.threads, false, "Processor", kernelTLS().this_processor );
    460457                }
    461458                else {
    462459                        __atomic_fetch_add(&cl->stats->ready.threads.threads, 1, __ATOMIC_RELAXED);
    463                         __push_stat( cl->stats, cl->stats->ready.threads.threads, true, "Cluster", cl );
    464460                }
    465461        #endif
     
    474470
    475471        ready_schedule_lock();
    476                 $thread * thrd = pop_fast( this );
     472                $thread * thrd = pop( this );
    477473        ready_schedule_unlock();
    478474
     
    617613        unsigned idle;
    618614        unsigned total;
    619         [idle, total, p] = query_idles(this->procs);
     615        [idle, total, p] = query(this->idles);
    620616
    621617        // If no one is sleeping, we are done
     
    654650}
    655651
    656 static void mark_idle(__cluster_proc_list & this, processor & proc) {
     652static void push  (__cluster_idles & this, processor & proc) {
    657653        /* paranoid */ verify( ! __preemption_enabled() );
    658654        lock( this );
    659655                this.idle++;
    660656                /* paranoid */ verify( this.idle <= this.total );
    661                 remove(proc);
    662                 insert_first(this.idles, proc);
     657
     658                insert_first(this.list, proc);
    663659        unlock( this );
    664660        /* paranoid */ verify( ! __preemption_enabled() );
    665661}
    666662
    667 static void mark_awake(__cluster_proc_list & this, processor & proc) {
     663static void remove(__cluster_idles & this, processor & proc) {
    668664        /* paranoid */ verify( ! __preemption_enabled() );
    669665        lock( this );
    670666                this.idle--;
    671667                /* paranoid */ verify( this.idle >= 0 );
     668
    672669                remove(proc);
    673                 insert_last(this.actives, proc);
    674670        unlock( this );
    675671        /* paranoid */ verify( ! __preemption_enabled() );
    676672}
    677673
    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 
     674static [unsigned idle, unsigned total, * processor] query( & __cluster_idles this ) {
    682675        for() {
    683676                uint64_t l = __atomic_load_n(&this.lock, __ATOMIC_SEQ_CST);
     
    685678                unsigned idle    = this.idle;
    686679                unsigned total   = this.total;
    687                 processor * proc = &this.idles`first;
     680                processor * proc = &this.list`first;
    688681                // Compiler fence is unnecessary, but gcc-8 and older incorrectly reorder code without it
    689682                asm volatile("": : :"memory");
     
    691684                return [idle, total, proc];
    692685        }
    693 
    694         /* paranoid */ verify( ready_schedule_islocked() );
    695         /* paranoid */ verify( ! __preemption_enabled() );
    696686}
    697687
Note: See TracChangeset for help on using the changeset viewer.