Ignore:
Timestamp:
Jan 31, 2018, 5:50:34 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
295e5071
Parents:
bc6f918 (diff), 281806b (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/monitor.c

    rbc6f918 re2e7330  
    5353static inline __lock_size_t aggregate    ( monitor_desc * storage [], const __waitfor_mask_t & mask );
    5454
    55 #ifndef __CFA_LOCK_NO_YIELD
    56 #define DO_LOCK lock_yield
    57 #else
    58 #define DO_LOCK lock
    59 #endif
    60 
    6155//-----------------------------------------------------------------------------
    6256// Useful defines
     
    9084        static void __enter_monitor_desc( monitor_desc * this, const __monitor_group_t & group ) {
    9185                // Lock the monitor spinlock
    92                 DO_LOCK( this->lock __cfaabi_dbg_ctx2 );
     86                lock( this->lock __cfaabi_dbg_ctx2 );
    9387                thread_desc * thrd = this_thread;
     88
     89                verify( disable_preempt_count > 0 );
    9490
    9591                __cfaabi_dbg_print_safe("Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
     
    121117                        // Some one else has the monitor, wait in line for it
    122118                        append( this->entry_queue, thrd );
     119
     120                        verify( disable_preempt_count > 0 );
     121
    123122                        BlockInternal( &this->lock );
    124123
     
    138137        static void __enter_monitor_dtor( monitor_desc * this, fptr_t func ) {
    139138                // Lock the monitor spinlock
    140                 DO_LOCK( this->lock __cfaabi_dbg_ctx2 );
     139                lock( this->lock __cfaabi_dbg_ctx2 );
    141140                thread_desc * thrd = this_thread;
    142141
     
    201200        // Leave single monitor
    202201        void __leave_monitor_desc( monitor_desc * this ) {
    203                 // Lock the monitor spinlock, DO_LOCK to reduce contention
    204                 DO_LOCK( this->lock __cfaabi_dbg_ctx2 );
     202                // Lock the monitor spinlock
     203                lock( this->lock __cfaabi_dbg_ctx2 );
    205204
    206205                __cfaabi_dbg_print_safe("Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);
     
    248247
    249248                // Lock the monitor now
    250                 DO_LOCK( this->lock __cfaabi_dbg_ctx2 );
     249                lock( this->lock __cfaabi_dbg_ctx2 );
    251250
    252251                disable_interrupts();
     
    397396        append( this.blocked, &waiter );
    398397
     398        verify( disable_preempt_count == 0 );
     399
    399400        // Lock all monitors (aggregates the locks as well)
    400401        lock_all( monitors, locks, count );
     402
     403        // verifyf( disable_preempt_count == count, "Got %d, expected %d\n", disable_preempt_count, count );
     404        if(disable_preempt_count != count) { __cfaabi_dbg_print_buffer_decl("----------Gonna crash\n"); }
    401405
    402406        // Find the next thread(s) to run
     
    473477        monitor_ctx( this.monitors, this.monitor_count );
    474478
     479        verify( disable_preempt_count == 0 );
     480
    475481        // Lock all monitors (aggregates the locks them as well)
    476482        lock_all( monitors, locks, count );
     483
     484        // verify( disable_preempt_count == count );
     485        if(disable_preempt_count != count) { __cfaabi_dbg_print_buffer_decl("----------Gonna crash\n"); }
     486
    477487
    478488        // Create the node specific to this wait operation
     
    737747static inline void lock_all( __spinlock_t * locks [], __lock_size_t count ) {
    738748        for( __lock_size_t i = 0; i < count; i++ ) {
    739                 DO_LOCK( *locks[i] __cfaabi_dbg_ctx2 );
     749                lock( *locks[i] __cfaabi_dbg_ctx2 );
    740750        }
    741751}
     
    744754        for( __lock_size_t i = 0; i < count; i++ ) {
    745755                __spinlock_t * l = &source[i]->lock;
    746                 DO_LOCK( *l __cfaabi_dbg_ctx2 );
     756                lock( *l __cfaabi_dbg_ctx2 );
    747757                if(locks) locks[i] = l;
    748758        }
Note: See TracChangeset for help on using the changeset viewer.