Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/bits/locks.h

    r2e9aed4 rb158d8f  
    5858
    5959#ifdef __cforall
    60         extern "C" {
    61                 extern void disable_interrupts();
    62                 extern void enable_interrupts_noPoll();
    63         }
    64 
    6560        extern void yield( unsigned int );
    6661        extern thread_local struct thread_desc *    volatile this_thread;
    67         extern thread_local struct processor *      volatile this_processor;
    6862
    6963        static inline void ?{}( __spinlock_t & this ) {
     
    7468        static inline _Bool try_lock  ( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) {
    7569                _Bool result = __lock_test_and_test_and_set( this.lock );
    76                 if( result ) {
    77                         disable_interrupts();
    78                         __cfaabi_dbg_debug_do(
     70                __cfaabi_dbg_debug_do(
     71                        if( result ) {
    7972                                this.prev_name = caller;
    8073                                this.prev_thrd = this_thread;
    81                         )
    82                 }
     74                        }
     75                )
    8376                return result;
    8477        }
     
    10699                        #endif
    107100                }
    108                 disable_interrupts();
    109101                __cfaabi_dbg_debug_do(
    110102                        this.prev_name = caller;
     
    113105        }
    114106
    115         // // Lock the spinlock, yield if already acquired
    116         // static inline void lock_yield( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) {
    117         //      for ( unsigned int i = 1;; i += 1 ) {
    118         //              if ( __lock_test_and_test_and_set( this.lock ) ) break;
    119         //              yield( i );
    120         //      }
    121         //      disable_interrupts();
    122         //      __cfaabi_dbg_debug_do(
    123         //              this.prev_name = caller;
    124         //              this.prev_thrd = this_thread;
    125         //      )
    126         // }
     107        // Lock the spinlock, spin if already acquired
     108        static inline void lock_yield( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) {
     109                for ( unsigned int i = 1;; i += 1 ) {
     110                        if ( __lock_test_and_test_and_set( this.lock ) ) break;
     111                        yield( i );
     112                }
     113                __cfaabi_dbg_debug_do(
     114                        this.prev_name = caller;
     115                        this.prev_thrd = this_thread;
     116                )
     117        }
    127118
    128119        static inline void unlock( __spinlock_t & this ) {
    129                 enable_interrupts_noPoll();
    130120                __lock_release( this.lock );
    131121        }
Note: See TracChangeset for help on using the changeset viewer.