Changeset 6a5be52 for src/libcfa/concurrency/monitor.c
- Timestamp:
- Oct 27, 2017, 5:54:56 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- af0c8da
- Parents:
- 9f0b975
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/monitor.c
r9f0b975 r6a5be52 95 95 else if( this->owner == thrd) { 96 96 // We already have the monitor, just note how many times we took it 97 verify( this->recursion > 0 );98 97 this->recursion += 1; 99 98 … … 207 206 // it means we don't need to do anything 208 207 if( this->recursion != 0) { 208 LIB_DEBUG_PRINT_SAFE("Kernel : recursion still %d\n", this->recursion); 209 209 unlock( &this->lock ); 210 210 return; … … 536 536 short actual_count = aggregate( mon_storage, mask ); 537 537 538 LIB_DEBUG_PRINT_ SAFE("Kernel : waitfor %d (s: %d, m: %d)\n", actual_count, mask.size, (short)max);538 LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : waitfor %d (s: %d, m: %d)\n", actual_count, mask.size, (short)max); 539 539 540 540 if(actual_count == 0) return; 541 541 542 LIB_DEBUG_PRINT_ SAFE("Kernel : waitfor internal proceeding\n");542 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : waitfor internal proceeding\n"); 543 543 544 544 // Create storage for monitor context … … 556 556 *mask.accepted = index; 557 557 if( mask.clauses[index].is_dtor ) { 558 LIB_DEBUG_PRINT_ SAFE("Kernel : dtor already there\n");558 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : dtor already there\n"); 559 559 verifyf( mask.clauses[index].size == 1 , "ERROR: Accepted dtor has more than 1 mutex parameter." ); 560 560 … … 568 568 } 569 569 else { 570 LIB_DEBUG_PRINT_ SAFE("Kernel : thread present, baton-passing\n");570 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : thread present, baton-passing\n"); 571 571 572 572 // Create the node specific to this wait operation … … 576 576 monitor_save; 577 577 578 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : baton of %d monitors : ", count ); 579 #ifdef __CFA_DEBUG_PRINT__ 580 for( int i = 0; i < count; i++) { 581 LIB_DEBUG_PRINT_BUFFER_LOCAL( "%p %p ", monitors[i], monitors[i]->signal_stack.top ); 582 } 583 #endif 584 LIB_DEBUG_PRINT_BUFFER_LOCAL( "\n"); 585 578 586 // Set the owners to be the next thread 579 587 set_owner( monitors, count, next ); … … 585 593 monitor_restore; 586 594 587 LIB_DEBUG_PRINT_ SAFE("Kernel : thread present, returned\n");595 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : thread present, returned\n"); 588 596 } 589 597 590 LIB_DEBUG_PRINT_ SAFE("Kernel : accepted %d\n", *mask.accepted);598 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : accepted %d\n", *mask.accepted); 591 599 592 600 return; … … 596 604 597 605 if( duration == 0 ) { 598 LIB_DEBUG_PRINT_ SAFE("Kernel : non-blocking, exiting\n");606 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : non-blocking, exiting\n"); 599 607 600 608 unlock_all( locks, count ); 601 609 602 LIB_DEBUG_PRINT_ SAFE("Kernel : accepted %d\n", *mask.accepted);610 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : accepted %d\n", *mask.accepted); 603 611 return; 604 612 } … … 607 615 verifyf( duration < 0, "Timeout on waitfor statments not supported yet."); 608 616 609 LIB_DEBUG_PRINT_ SAFE("Kernel : blocking waitfor\n");617 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : blocking waitfor\n"); 610 618 611 619 // Create the node specific to this wait operation … … 629 637 monitor_restore; 630 638 631 LIB_DEBUG_PRINT_ SAFE("Kernel : exiting\n");632 633 LIB_DEBUG_PRINT_ SAFE("Kernel : accepted %d\n", *mask.accepted);639 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : exiting\n"); 640 641 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : accepted %d\n", *mask.accepted); 634 642 } 635 643 … … 648 656 649 657 static inline void set_owner( monitor_desc ** monitors, short count, thread_desc * owner ) { 650 for( int i = 0; i < count; i++ ) { 651 set_owner( monitors[i], owner ); 658 monitors[0]->owner = owner; 659 monitors[0]->recursion = 1; 660 for( int i = 1; i < count; i++ ) { 661 monitors[i]->owner = owner; 662 monitors[i]->recursion = 0; 652 663 } 653 664 } … … 667 678 static inline thread_desc * next_thread( monitor_desc * this ) { 668 679 //Check the signaller stack 680 LIB_DEBUG_PRINT_SAFE("Kernel : mon %p AS-stack top %p\n", this, this->signal_stack.top); 669 681 __condition_criterion_t * urgent = pop( &this->signal_stack ); 670 682 if( urgent ) { … … 718 730 for(int i = 0; i < count; i++) { 719 731 (criteria[i]){ monitors[i], waiter }; 732 LIB_DEBUG_PRINT_SAFE( "Kernel : target %p = %p\n", criteria[i].target, &criteria[i] ); 720 733 push( &criteria[i].target->signal_stack, &criteria[i] ); 721 734 } … … 788 801 } 789 802 790 // LIB_DEBUG_PRINT_SAFE( "Runing %i\n", ready2run);803 LIB_DEBUG_PRINT_SAFE( "Kernel : Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL ); 791 804 return ready2run ? node->waiting_thread : NULL; 792 805 } … … 856 869 short size = 0; 857 870 for( int i = 0; i < mask.size; i++ ) { 871 qsort( mask.clauses[i].list, mask.clauses[i].size ); 858 872 for( int j = 0; j < mask.clauses[i].size; j++) { 859 873 insert_unique( storage, size, mask.clauses[i].list[j] ); 860 874 } 861 875 } 876 // TODO insertion sort instead of this 862 877 qsort( storage, size ); 863 878 return size;
Note: See TracChangeset
for help on using the changeset viewer.