Changeset 24e321c for libcfa/src/concurrency/ready_queue.cfa
- Timestamp:
- Sep 23, 2021, 2:18:01 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 75c7252
- Parents:
- fcd65ca
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/ready_queue.cfa
rfcd65ca r24e321c 290 290 //----------------------------------------------------------------------- 291 291 #if defined(USE_CPU_WORK_STEALING) 292 __attribute__((hot)) void push(struct cluster * cltr, struct thread$ * thrd, bool push_local) with (cltr->ready_queue) {292 __attribute__((hot)) void push(struct cluster * cltr, struct thread$ * thrd, unpark_hint hint) with (cltr->ready_queue) { 293 293 __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr); 294 294 … … 450 450 } 451 451 452 __attribute__((hot)) void push(struct cluster * cltr, struct thread$ * thrd, bool push_local) with (cltr->ready_queue) {452 __attribute__((hot)) void push(struct cluster * cltr, struct thread$ * thrd, unpark_hint hint) with (cltr->ready_queue) { 453 453 __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr); 454 454 455 const bool external = !push_local|| (!kernelTLS().this_processor) || (cltr != kernelTLS().this_processor->cltr);455 const bool external = (hint != UNPARK_LOCAL) || (!kernelTLS().this_processor) || (cltr != kernelTLS().this_processor->cltr); 456 456 /* paranoid */ verify(external || kernelTLS().this_processor->rdq.id < lanes.count ); 457 457 … … 537 537 #endif 538 538 #if defined(USE_WORK_STEALING) 539 __attribute__((hot)) void push(struct cluster * cltr, struct thread$ * thrd, bool push_local) with (cltr->ready_queue) {539 __attribute__((hot)) void push(struct cluster * cltr, struct thread$ * thrd, unpark_hint hint) with (cltr->ready_queue) { 540 540 __cfadbg_print_safe(ready_queue, "Kernel : Pushing %p on cluster %p\n", thrd, cltr); 541 541 542 542 // #define USE_PREFERRED 543 543 #if !defined(USE_PREFERRED) 544 const bool external = !push_local|| (!kernelTLS().this_processor) || (cltr != kernelTLS().this_processor->cltr);544 const bool external = (hint != UNPARK_LOCAL) || (!kernelTLS().this_processor) || (cltr != kernelTLS().this_processor->cltr); 545 545 /* paranoid */ verify(external || kernelTLS().this_processor->rdq.id < lanes.count ); 546 546 #else 547 547 unsigned preferred = thrd->preferred; 548 const bool external = push_local|| (!kernelTLS().this_processor) || preferred == -1u || thrd->curr_cluster != cltr;548 const bool external = (hint != UNPARK_LOCAL) || (!kernelTLS().this_processor) || preferred == -1u || thrd->curr_cluster != cltr; 549 549 /* paranoid */ verifyf(external || preferred < lanes.count, "Invalid preferred queue %u for %u lanes", preferred, lanes.count ); 550 550 … … 687 687 #endif 688 688 689 thrd->preferred = w; 689 #if defined(USE_CPU_WORK_STEALING) 690 thrd->preferred = w / READYQ_SHARD_FACTOR; 691 #else 692 thrd->preferred = w; 693 #endif 690 694 691 695 // return the popped thread … … 713 717 714 718 //----------------------------------------------------------------------- 719 // get preferred ready for new thread 720 unsigned ready_queue_new_preferred() { 721 unsigned pref = 0; 722 if(struct thread$ * thrd = publicTLS_get( this_thread )) { 723 pref = thrd->preferred; 724 } 725 else { 726 #if defined(USE_CPU_WORK_STEALING) 727 pref = __kernel_getcpu(); 728 #endif 729 } 730 731 #if defined(USE_CPU_WORK_STEALING) 732 /* paranoid */ verify(pref >= 0); 733 /* paranoid */ verify(pref < cpu_info.hthrd_count); 734 #endif 735 736 return pref; 737 } 738 739 //----------------------------------------------------------------------- 715 740 // Check that all the intrusive queues in the data structure are still consistent 716 741 static void check( __ready_queue_t & q ) with (q) {
Note: See TracChangeset
for help on using the changeset viewer.