Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/locks.cfa

    r848439f rbe73f30  
    7474
    7575void lock( blocking_lock & this ) with( this ) {
     76        $thread * thrd = active_thread();
    7677        lock( lock __cfaabi_dbg_ctx2 );
    77         if ( owner == kernelTLS.this_thread && !multi_acquisition) {
     78        if ( owner == thrd && !multi_acquisition) {
    7879                fprintf(stderr, "A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock."); // Possibly throw instead
    7980                exit(EXIT_FAILURE);
    80         } else if ( owner != 0p && owner != kernelTLS.this_thread ) {
    81                 append( blocked_threads, kernelTLS.this_thread );
     81        } else if ( owner != 0p && owner != thrd ) {
     82                append( blocked_threads, thrd );
    8283                wait_count++;
    8384                unlock( lock );
    8485                park( __cfaabi_dbg_ctx );
    85         } else if ( owner == kernelTLS.this_thread && multi_acquisition ) {
     86        } else if ( owner == thrd && multi_acquisition ) {
    8687                recursion_count++;
    8788                unlock( lock );
    8889        } else {
    89                 owner = kernelTLS.this_thread;
     90                owner = thrd;
    9091                recursion_count = 1;
    9192                unlock( lock );
     
    9495
    9596bool try_lock( blocking_lock & this ) with( this ) {
     97        $thread * thrd = active_thread();
    9698        bool ret = false;
    9799        lock( lock __cfaabi_dbg_ctx2 );
    98100        if ( owner == 0p ) {
    99                 owner = kernelTLS.this_thread;
     101                owner = thrd;
    100102                if ( multi_acquisition ) recursion_count = 1;
    101103                ret = true;
    102         } else if ( owner == kernelTLS.this_thread && multi_acquisition ) {
     104        } else if ( owner == thrd && multi_acquisition ) {
    103105                recursion_count++;
    104106                ret = true;
     
    113115                fprintf( stderr, "There was an attempt to release a lock that isn't held" );
    114116                return;
    115         } else if ( strict_owner && owner != kernelTLS.this_thread ) {
     117        } else if ( strict_owner && owner != active_thread() ) {
    116118                fprintf( stderr, "A thread other than the owner attempted to release an owner lock" );
    117119                return;
     
    159161        if ( owner == 0p ){ // no owner implies lock isn't held
    160162                fprintf( stderr, "A lock that is not held was passed to a synchronization lock" );
    161         } else if ( strict_owner && owner != kernelTLS.this_thread ) {
     163        } else if ( strict_owner && owner != active_thread() ) {
    162164                fprintf( stderr, "A thread other than the owner of a lock passed it to a synchronization lock" );
    163165        } else {
     
    317319
    318320        void wait( synchronization_lock(L) & this ) with(this) {
    319                 info_thread( L ) i = { kernelTLS.this_thread };
     321                info_thread( L ) i = { active_thread() };
    320322                queue_info_thread( this, i );
    321323        }
    322324
    323325        void wait( synchronization_lock(L) & this, uintptr_t info ) with(this) {
    324                 info_thread( L ) i = { kernelTLS.this_thread, info };
     326                info_thread( L ) i = { active_thread(), info };
    325327                queue_info_thread( this, i );
    326328        }
     
    360362
    361363        void wait( synchronization_lock(L) & this, L & l ) with(this) {
    362                 info_thread(L) i = { kernelTLS.this_thread };
     364                info_thread(L) i = { active_thread() };
    363365                queue_info_thread_unlock( this, l, i );
    364366        }
    365367
    366368        void wait( synchronization_lock(L) & this, L & l, uintptr_t info ) with(this) {
    367                 info_thread(L) i = { kernelTLS.this_thread, info };
     369                info_thread(L) i = { active_thread(), info };
    368370                queue_info_thread_unlock( this, l, i );
    369371        }
Note: See TracChangeset for help on using the changeset viewer.