Changeset cf5e5b1


Ignore:
Timestamp:
May 31, 2018, 11:24:50 AM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
4e7cc5ce, b368dd8
Parents:
25fcb84 (diff), ae32d96 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

Location:
src/libcfa
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/bits/containers.h

    r25fcb84 rcf5e5b1  
    186186
    187187        forall(dtype T | is_node(T))
    188         static inline bool ?!=?( __queue(T) & this, zero_t zero ) with( this ) {
    189                 return head != 0;
     188        static inline bool ?!=?( __queue(T) & this, zero_t zero ) {
     189                return this.head != 0;
    190190        }
    191191#endif
     
    266266                __get( node ).prev = NULL;
    267267        }
     268
     269        forall(dtype T | sized(T))
     270        static inline bool ?!=?( __dllist(T) & this, zero_t zero ) {
     271                return this.head != 0;
     272        }
    268273        #undef next
    269274        #undef prev
  • src/libcfa/concurrency/kernel

    r25fcb84 rcf5e5b1  
    2323extern "C" {
    2424#include <pthread.h>
     25#include <semaphore.h>
    2526}
    2627
     
    131132
    132133        // Idle lock
     134        sem_t idleLock;
    133135
    134136        // Link lists fields
  • src/libcfa/concurrency/kernel.c

    r25fcb84 rcf5e5b1  
    143143        runner.proc = &this;
    144144
     145        sem_init(&idleLock, 0, 0);
     146
    145147        start( &this );
    146148}
     
    156158                pthread_join( kernel_thread, NULL );
    157159        }
     160
     161        sem_destroy(&idleLock);
    158162}
    159163
     
    289293// TODO : find some strategy to put cores to sleep after some time
    290294void spin(processor * this, unsigned int * spin_count) {
    291         (*spin_count)++;
     295        // (*spin_count)++;
     296        halt(this);
    292297}
    293298
     
    394399        with( *thrd->curr_cluster ) {
    395400                lock  ( ready_queue_lock __cfaabi_dbg_ctx2 );
     401                bool was_empty = !(ready_queue != 0);
    396402                append( ready_queue, thrd );
    397403                unlock( ready_queue_lock );
     404
     405                if( was_empty ) {
     406                        lock      (proc_list_lock __cfaabi_dbg_ctx2);
     407                        if(idles) {
     408                                wake(idles.head);
     409                        }
     410                        unlock    (proc_list_lock);
     411                }
    398412        }
    399413
     
    639653//=============================================================================================
    640654
    641 // void halt(processor * this) with( this ) {
    642 //      pthread_mutex_lock( &idle.lock );
    643 
    644 
    645 
    646 //      // SKULLDUGGERY: Even if spurious wake-up is a thing
    647 //      // spuriously waking up a kernel thread is not a big deal
    648 //      // if it is very rare.
    649 //      pthread_cond_wait( &idle.cond, &idle.lock);
    650 //      pthread_mutex_unlock( &idle.lock );
    651 // }
    652 
    653 // void wake(processor * this) with( this ) {
    654 //      pthread_mutex_lock  (&idle.lock);
    655 //      pthread_cond_signal (&idle.cond);
    656 //      pthread_mutex_unlock(&idle.lock);
    657 // }
     655void halt(processor * this) with( *this ) {
     656        with( *cltr ) {
     657                lock      (proc_list_lock __cfaabi_dbg_ctx2);
     658                remove    (procs, *this);
     659                push_front(idles, *this);
     660                unlock    (proc_list_lock);
     661        }
     662
     663        __cfaabi_dbg_print_safe("Kernel : Processor %p ready to sleep\n", this);
     664
     665        sem_wait(&idleLock);
     666
     667        __cfaabi_dbg_print_safe("Kernel : Processor %p woke up and ready to run\n", this);
     668
     669        with( *cltr ) {
     670                lock      (proc_list_lock __cfaabi_dbg_ctx2);
     671                remove    (idles, *this);
     672                push_front(procs, *this);
     673                unlock    (proc_list_lock);
     674        }
     675}
     676
     677void wake(processor * this) {
     678        __cfaabi_dbg_print_safe("Kernel : Waking up processor %p\n", this);
     679        sem_post(&this->idleLock);
     680}
    658681
    659682//=============================================================================================
  • src/libcfa/concurrency/kernel_private.h

    r25fcb84 rcf5e5b1  
    5757void runThread(processor * this, thread_desc * dst);
    5858void finishRunning(processor * this);
     59void halt(processor * this);
     60void wake(processor * this);
    5961void terminate(processor * this);
    6062void spin(processor * this, unsigned int * spin_count);
  • src/libcfa/concurrency/mutex.c

    r25fcb84 rcf5e5b1  
    167167        }
    168168        BlockInternal( __unlock );
     169        lock(l);
    169170}
    170171
  • src/libcfa/concurrency/preemption.c

    r25fcb84 rcf5e5b1  
    266266void terminate(processor * this) {
    267267        this->do_terminate = true;
     268        wake(this);
    268269        sigval_t value = { PREEMPT_TERMINATE };
    269270        pthread_sigqueue( this->kernel_thread, SIGUSR1, value );
Note: See TracChangeset for help on using the changeset viewer.