Ignore:
Timestamp:
Jun 29, 2017, 11:59:09 AM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
b751c8e
Parents:
7bbba76
Message:

Commented some debug messages.
Monitors now yield when spinning.
Debug mode saves more information about previous locks and interrupts

File:
1 edited

Legend:

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

    r7bbba76 rb227f68  
    605605
    606606bool try_lock( spinlock * this DEBUG_CTX_PARAM2 ) {
    607         bool ret = this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0;
    608         LIB_DEBUG_DO( this->prev = caller; )
    609         return ret;
     607        return this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0;
    610608}
    611609
    612610void lock( spinlock * this DEBUG_CTX_PARAM2 ) {
    613611        for ( unsigned int i = 1;; i += 1 ) {
    614                 if ( this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0 ) break;
    615         }
    616         LIB_DEBUG_DO( this->prev = caller; )
    617 }
     612                if ( this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0 ) { break; }
     613        }
     614        LIB_DEBUG_DO(
     615                this->prev_name = caller;
     616                this->prev_thrd = this_thread;
     617        )
     618}
     619
     620void lock_yield( spinlock * this DEBUG_CTX_PARAM2 ) {
     621        for ( unsigned int i = 1;; i += 1 ) {
     622                if ( this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0 ) { break; }
     623                yield();
     624        }
     625        LIB_DEBUG_DO(
     626                this->prev_name = caller;
     627                this->prev_thrd = this_thread;
     628        )
     629}
     630
    618631
    619632void unlock( spinlock * this ) {
Note: See TracChangeset for help on using the changeset viewer.