Changes in / [cf5e5b1:25fcb84]
- Location:
- src/libcfa
- Files:
-
- 6 edited
-
bits/containers.h (modified) (2 diffs)
-
concurrency/kernel (modified) (2 diffs)
-
concurrency/kernel.c (modified) (5 diffs)
-
concurrency/kernel_private.h (modified) (1 diff)
-
concurrency/mutex.c (modified) (1 diff)
-
concurrency/preemption.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/bits/containers.h
rcf5e5b1 r25fcb84 186 186 187 187 forall(dtype T | is_node(T)) 188 static inline bool ?!=?( __queue(T) & this, zero_t zero ) {189 return this.head != 0;188 static inline bool ?!=?( __queue(T) & this, zero_t zero ) with( this ) { 189 return head != 0; 190 190 } 191 191 #endif … … 266 266 __get( node ).prev = NULL; 267 267 } 268 269 forall(dtype T | sized(T))270 static inline bool ?!=?( __dllist(T) & this, zero_t zero ) {271 return this.head != 0;272 }273 268 #undef next 274 269 #undef prev -
src/libcfa/concurrency/kernel
rcf5e5b1 r25fcb84 23 23 extern "C" { 24 24 #include <pthread.h> 25 #include <semaphore.h>26 25 } 27 26 … … 132 131 133 132 // Idle lock 134 sem_t idleLock;135 133 136 134 // Link lists fields -
src/libcfa/concurrency/kernel.c
rcf5e5b1 r25fcb84 143 143 runner.proc = &this; 144 144 145 sem_init(&idleLock, 0, 0);146 147 145 start( &this ); 148 146 } … … 158 156 pthread_join( kernel_thread, NULL ); 159 157 } 160 161 sem_destroy(&idleLock);162 158 } 163 159 … … 293 289 // TODO : find some strategy to put cores to sleep after some time 294 290 void spin(processor * this, unsigned int * spin_count) { 295 // (*spin_count)++; 296 halt(this); 291 (*spin_count)++; 297 292 } 298 293 … … 399 394 with( *thrd->curr_cluster ) { 400 395 lock ( ready_queue_lock __cfaabi_dbg_ctx2 ); 401 bool was_empty = !(ready_queue != 0);402 396 append( ready_queue, thrd ); 403 397 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 }412 398 } 413 399 … … 653 639 //============================================================================================= 654 640 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 // } 681 658 682 659 //============================================================================================= -
src/libcfa/concurrency/kernel_private.h
rcf5e5b1 r25fcb84 57 57 void runThread(processor * this, thread_desc * dst); 58 58 void finishRunning(processor * this); 59 void halt(processor * this);60 void wake(processor * this);61 59 void terminate(processor * this); 62 60 void spin(processor * this, unsigned int * spin_count); -
src/libcfa/concurrency/mutex.c
rcf5e5b1 r25fcb84 167 167 } 168 168 BlockInternal( __unlock ); 169 lock(l);170 169 } 171 170 -
src/libcfa/concurrency/preemption.c
rcf5e5b1 r25fcb84 266 266 void terminate(processor * this) { 267 267 this->do_terminate = true; 268 wake(this);269 268 sigval_t value = { PREEMPT_TERMINATE }; 270 269 pthread_sigqueue( this->kernel_thread, SIGUSR1, value );
Note:
See TracChangeset
for help on using the changeset viewer.