Ignore:
File:
1 edited

Legend:

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

    r6b4cdd3 r09800e9  
    143143        runner.proc = &this;
    144144
    145         sem_init(&idleLock, 0, 0);
    146 
    147145        start( &this );
    148146}
     
    158156                pthread_join( kernel_thread, NULL );
    159157        }
    160 
    161         sem_destroy(&idleLock);
    162158}
    163159
     
    293289// TODO : find some strategy to put cores to sleep after some time
    294290void spin(processor * this, unsigned int * spin_count) {
    295         // (*spin_count)++;
    296         halt(this);
     291        (*spin_count)++;
    297292}
    298293
     
    399394        with( *thrd->curr_cluster ) {
    400395                lock  ( ready_queue_lock __cfaabi_dbg_ctx2 );
    401                 bool was_empty = !(ready_queue != 0);
    402396                append( ready_queue, thrd );
    403397                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                 }
    412398        }
    413399
     
    653639//=============================================================================================
    654640
    655 void 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 
    677 void wake(processor * this) {
    678         __cfaabi_dbg_print_safe("Kernel : Waking up processor %p\n", this);
    679         sem_post(&this->idleLock);
    680 }
     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// }
    681658
    682659//=============================================================================================
Note: See TracChangeset for help on using the changeset viewer.