Ignore:
Timestamp:
Apr 10, 2018, 3:31:07 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, with_gc
Children:
33f5b57
Parents:
9d1e3f7 (diff), 8ad6533 (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

    r9d1e3f7 rca37445  
    1010// Created On       : Thd Feb 23 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb 16 14:49:53 2018
    13 // Update Count     : 5
     12// Last Modified On : Fri Mar 30 14:30:26 2018
     13// Update Count     : 9
    1414//
    1515
     
    8585                // Lock the monitor spinlock
    8686                lock( this->lock __cfaabi_dbg_ctx2 );
    87                 thread_desc * thrd = this_thread;
     87                thread_desc * thrd = TL_GET( this_thread );
    8888
    8989                __cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
     
    134134                // Lock the monitor spinlock
    135135                lock( this->lock __cfaabi_dbg_ctx2 );
    136                 thread_desc * thrd = this_thread;
     136                thread_desc * thrd = TL_GET( this_thread );
    137137
    138138                __cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner);
     
    168168
    169169                        // Create the node specific to this wait operation
    170                         wait_ctx_primed( this_thread, 0 )
     170                        wait_ctx_primed( TL_GET( this_thread ), 0 )
    171171
    172172                        // Some one else has the monitor, wait for him to finish and then run
     
    179179                        __cfaabi_dbg_print_safe( "Kernel :  blocking \n" );
    180180
    181                         wait_ctx( this_thread, 0 )
     181                        wait_ctx( TL_GET( this_thread ), 0 )
    182182                        this->dtor_node = &waiter;
    183183
     
    199199                lock( this->lock __cfaabi_dbg_ctx2 );
    200200
    201                 __cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);
    202 
    203                 verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", this_thread, this->owner, this->recursion, this );
     201                __cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", TL_GET( this_thread ), this, this->owner);
     202
     203                verifyf( TL_GET( this_thread ) == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", TL_GET( this_thread ), this->owner, this->recursion, this );
    204204
    205205                // Leaving a recursion level, decrement the counter
     
    227227        void __leave_dtor_monitor_desc( monitor_desc * this ) {
    228228                __cfaabi_dbg_debug_do(
    229                         if( this_thread != this->owner ) {
    230                                 abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, this_thread, this->owner);
     229                        if( TL_GET( this_thread ) != this->owner ) {
     230                                abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, TL_GET( this_thread ), this->owner);
    231231                        }
    232232                        if( this->recursion != 1 ) {
     
    297297
    298298        // Save previous thread context
    299         this.prev = this_thread->monitors;
     299        this.prev = TL_GET( this_thread )->monitors;
    300300
    301301        // Update thread context (needed for conditions)
    302         (this_thread->monitors){m, count, func};
     302        (TL_GET( this_thread )->monitors){m, count, func};
    303303
    304304        // __cfaabi_dbg_print_safe( "MGUARD : enter %d\n", count);
     
    322322
    323323        // Restore thread context
    324         this_thread->monitors = this.prev;
     324        TL_GET( this_thread )->monitors = this.prev;
    325325}
    326326
     
    332332
    333333        // Save previous thread context
    334         this.prev = this_thread->monitors;
     334        this.prev = TL_GET( this_thread )->monitors;
    335335
    336336        // Update thread context (needed for conditions)
    337         (this_thread->monitors){m, 1, func};
     337        (TL_GET( this_thread )->monitors){m, 1, func};
    338338
    339339        __enter_monitor_dtor( this.m, func );
     
    346346
    347347        // Restore thread context
    348         this_thread->monitors = this.prev;
     348        TL_GET( this_thread )->monitors = this.prev;
    349349}
    350350
     
    386386
    387387        // Create the node specific to this wait operation
    388         wait_ctx( this_thread, user_info );
     388        wait_ctx( TL_GET( this_thread ), user_info );
    389389
    390390        // Append the current wait operation to the ones already queued on the condition
     
    425425        //Some more checking in debug
    426426        __cfaabi_dbg_debug_do(
    427                 thread_desc * this_thrd = this_thread;
     427                thread_desc * this_thrd = TL_GET( this_thread );
    428428                if ( this.monitor_count != this_thrd->monitors.size ) {
    429429                        abort( "Signal on condition %p made with different number of monitor(s), expected %zi got %zi", &this, this.monitor_count, this_thrd->monitors.size );
     
    473473
    474474        // Create the node specific to this wait operation
    475         wait_ctx_primed( this_thread, 0 )
     475        wait_ctx_primed( TL_GET( this_thread ), 0 )
    476476
    477477        //save contexts
     
    566566
    567567                                // Create the node specific to this wait operation
    568                                 wait_ctx_primed( this_thread, 0 );
     568                                wait_ctx_primed( TL_GET( this_thread ), 0 );
    569569
    570570                                // Save monitor states
     
    612612
    613613        // Create the node specific to this wait operation
    614         wait_ctx_primed( this_thread, 0 );
     614        wait_ctx_primed( TL_GET( this_thread ), 0 );
    615615
    616616        monitor_save;
     
    618618
    619619        for( __lock_size_t i = 0; i < count; i++) {
    620                 verify( monitors[i]->owner == this_thread );
     620                verify( monitors[i]->owner == TL_GET( this_thread ) );
    621621        }
    622622
     
    812812
    813813static inline void brand_condition( condition & this ) {
    814         thread_desc * thrd = this_thread;
     814        thread_desc * thrd = TL_GET( this_thread );
    815815        if( !this.monitors ) {
    816816                // __cfaabi_dbg_print_safe( "Branding\n" );
Note: See TracChangeset for help on using the changeset viewer.