Changeset b227f68 for src/libcfa/concurrency/kernel.c
- Timestamp:
- Jun 29, 2017, 11:59:09 AM (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:
- b751c8e
- Parents:
- 7bbba76
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel.c
r7bbba76 rb227f68 605 605 606 606 bool 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; 610 608 } 611 609 612 610 void lock( spinlock * this DEBUG_CTX_PARAM2 ) { 613 611 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 620 void 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 618 631 619 632 void unlock( spinlock * this ) {
Note: See TracChangeset
for help on using the changeset viewer.