Changeset 8cfa4ef for libcfa/src/concurrency/ready_queue.cfa
- Timestamp:
- Apr 15, 2021, 12:05:16 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8590328
- Parents:
- 2f5ea69 (diff), a4b0aa4 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/ready_queue.cfa
r2f5ea69 r8cfa4ef 94 94 //======================================================================= 95 95 // Lock-Free registering/unregistering of threads 96 unsigned doregister( struct __processor_id_t * proc ) with(*__scheduler_lock) {96 void register_proc_id( struct __processor_id_t * proc ) with(*__scheduler_lock) { 97 97 __cfadbg_print_safe(ready_queue, "Kernel : Registering proc %p for RW-Lock\n", proc); 98 98 … … 108 108 /*paranoid*/ verify(0 == (__alignof__(data[i]) % cache_line_size)); 109 109 /*paranoid*/ verify((((uintptr_t)&data[i]) % cache_line_size) == 0); 110 returni;110 proc->id = i; 111 111 } 112 112 } … … 135 135 /*paranoid*/ verify(__alignof__(data[n]) == (2 * cache_line_size)); 136 136 /*paranoid*/ verify((((uintptr_t)&data[n]) % cache_line_size) == 0); 137 returnn;138 } 139 140 void unregister ( struct __processor_id_t * proc ) with(*__scheduler_lock) {137 proc->id = n; 138 } 139 140 void unregister_proc_id( struct __processor_id_t * proc ) with(*__scheduler_lock) { 141 141 unsigned id = proc->id; 142 142 /*paranoid*/ verify(id < ready); … … 254 254 __attribute__((unused)) int preferred; 255 255 #if defined(BIAS) 256 /* paranoid */ verify(external || kernelTLS().this_processor->cltr_id < lanes.count ); 256 257 preferred = 257 258 //* … … 344 345 int preferred; 345 346 #if defined(BIAS) 346 / / Don't bother trying locally too much347 /* paranoid */ verify(kernelTLS().this_processor->cltr_id < lanes.count ); 347 348 preferred = kernelTLS().this_processor->cltr_id; 348 349 #endif … … 541 542 } 542 543 544 static void assign_list(unsigned & value, const int inc, dlist(processor, processor) & list, unsigned count) { 545 processor * it = &list`first; 546 for(unsigned i = 0; i < count; i++) { 547 /* paranoid */ verifyf( it, "Unexpected null iterator, at index %u of %u\n", i, count); 548 it->cltr_id = value; 549 value += inc; 550 it = &(*it)`next; 551 } 552 } 553 554 static void reassign_cltr_id(struct cluster * cltr, const int inc) { 555 unsigned preferred = 0; 556 assign_list(preferred, inc, cltr->procs.actives, cltr->procs.total - cltr->procs.idle); 557 assign_list(preferred, inc, cltr->procs.idles , cltr->procs.idle ); 558 } 559 543 560 // Grow the ready queue 544 unsigned ready_queue_grow(struct cluster * cltr, int target) { 545 unsigned preferred; 561 void ready_queue_grow(struct cluster * cltr) { 546 562 size_t ncount; 563 int target = cltr->procs.total; 547 564 548 565 /* paranoid */ verify( ready_mutate_islocked() ); … … 562 579 if(target >= 2) { 563 580 ncount = target * 4; 564 preferred = ncount - 4;565 581 } else { 566 582 ncount = 1; 567 preferred = 0;568 583 } 569 584 … … 595 610 } 596 611 612 reassign_cltr_id(cltr, 4); 613 597 614 // Make sure that everything is consistent 598 615 /* paranoid */ check( cltr->ready_queue ); … … 601 618 602 619 /* paranoid */ verify( ready_mutate_islocked() ); 603 return preferred;604 620 } 605 621 606 622 // Shrink the ready queue 607 void ready_queue_shrink(struct cluster * cltr , int target) {623 void ready_queue_shrink(struct cluster * cltr) { 608 624 /* paranoid */ verify( ready_mutate_islocked() ); 609 625 __cfadbg_print_safe(ready_queue, "Kernel : Shrinking ready queue\n"); … … 611 627 // Make sure that everything is consistent 612 628 /* paranoid */ check( cltr->ready_queue ); 629 630 int target = cltr->procs.total; 613 631 614 632 with( cltr->ready_queue ) { … … 679 697 } 680 698 699 reassign_cltr_id(cltr, 4); 700 681 701 // Make sure that everything is consistent 682 702 /* paranoid */ check( cltr->ready_queue );
Note: See TracChangeset
for help on using the changeset viewer.