Changeset c84b4be for libcfa/src/concurrency/ready_queue.cfa
- Timestamp:
- Dec 13, 2019, 1:45:49 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 75ca7f4
- Parents:
- 983edfd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/ready_queue.cfa
r983edfd rc84b4be 240 240 this.lock = false; 241 241 this.last_id = -1u; 242 this.count = 0u; 242 243 243 244 this.before.link.prev = 0p; … … 283 284 /* paranoid */ verify(tail(this)->link.next == 0p ); 284 285 /* paranoid */ verify(tail(this)->link.prev == head(this) ); 286 /* paranoid */ verify(this.count == 0u ); 285 287 } 286 288 … … 292 294 verify(node->link.next == 0p); 293 295 verify(node->link.prev == 0p); 296 297 this.count++; 294 298 295 299 if(this.before.link.ts == 0l) { … … 345 349 } 346 350 351 this.count--; 347 352 /* paranoid */ verify(node); 348 353 … … 693 698 void ready_queue_grow (struct cluster * cltr) { 694 699 uint_fast32_t last_size = ready_mutate_lock( *cltr ); 700 __cfaabi_dbg_print_safe("Kernel : Growing ready queue\n"); 695 701 check( cltr->ready_queue ); 696 702 … … 723 729 // Make sure that everything is consistent 724 730 check( cltr->ready_queue ); 731 __cfaabi_dbg_print_safe("Kernel : Growing ready queue done\n"); 725 732 ready_mutate_unlock( *cltr, last_size ); 726 733 } … … 728 735 void ready_queue_shrink(struct cluster * cltr) { 729 736 uint_fast32_t last_size = ready_mutate_lock( *cltr ); 737 __cfaabi_dbg_print_safe("Kernel : Shrinking ready queue\n"); 730 738 with( cltr->ready_queue ) { 739 #if defined(__CFA_WITH_VERIFY__) 740 size_t nthreads = 0; 741 for( idx; (size_t)list.count ) { 742 nthreads += list.data[idx].count; 743 } 744 #endif 745 731 746 size_t ocount = list.count; 732 747 // Check that we have some space left … … 737 752 // redistribute old data 738 753 verify(ocount > list.count); 754 __attribute__((unused)) size_t displaced = 0; 739 755 for( idx; (size_t)list.count ~ ocount) { 740 756 // This is not strictly needed but makes checking invariants much easier … … 747 763 verify(thrd); 748 764 push(cltr, thrd); 765 displaced++; 749 766 } 750 767 … … 755 772 ^(list.data[idx]){}; 756 773 } 774 775 __cfaabi_dbg_print_safe("Kernel : Shrinking ready queue displaced %zu threads\n", displaced); 757 776 758 777 // clear the now unused masks … … 776 795 777 796 empty.count = 0; 778 for( i ; lword ) {797 for( i ; 0 ~= lword ) { 779 798 empty.count += __builtin_popcountl(empty.mask[i]); 780 799 } … … 788 807 fix(list.data[idx]); 789 808 } 809 810 #if defined(__CFA_WITH_VERIFY__) 811 for( idx; (size_t)list.count ) { 812 nthreads -= list.data[idx].count; 813 } 814 assertf(nthreads == 0, "Shrinking changed number of threads"); 815 #endif 790 816 } 791 817 792 818 // Make sure that everything is consistent 793 819 check( cltr->ready_queue ); 820 __cfaabi_dbg_print_safe("Kernel : Shrinking ready queue done\n"); 794 821 ready_mutate_unlock( *cltr, last_size ); 795 822 }
Note: See TracChangeset
for help on using the changeset viewer.