Ignore:
File:
1 edited

Legend:

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

    r92e7631 r2026bb6  
    1010// Created On       : Tue Oct 31 15:14:38 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  4 13:03:19 2020
    13 // Update Count     : 11
     12// Last Modified On : Sat Aug 11 15:42:24 2018
     13// Update Count     : 10
    1414//
    1515
     
    5454
    5555                #ifdef __CFA_DEBUG__
    56                         void __cfaabi_dbg_record_lock(__spinlock_t & this, const char prev_name[]);
     56                        void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name);
    5757                #else
    58                         #define __cfaabi_dbg_record_lock(x, y)
     58                        #define __cfaabi_dbg_record(x, y)
    5959                #endif
    6060        }
     61
     62        extern void yield( unsigned int );
    6163
    6264        static inline void ?{}( __spinlock_t & this ) {
     
    6668        // Lock the spinlock, return false if already acquired
    6769        static inline bool try_lock  ( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) {
    68                 disable_interrupts();
    6970                bool result = (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0);
    7071                if( result ) {
    71                         __cfaabi_dbg_record_lock( this, caller );
    72                 } else {
    73                         enable_interrupts_noPoll();
     72                        disable_interrupts();
     73                        __cfaabi_dbg_record( this, caller );
    7474                }
    7575                return result;
     
    8383                #endif
    8484
    85                 disable_interrupts();
    8685                for ( unsigned int i = 1;; i += 1 ) {
    8786                        if ( (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0) ) break;
     
    9998                        #endif
    10099                }
    101                 __cfaabi_dbg_record_lock( this, caller );
     100                disable_interrupts();
     101                __cfaabi_dbg_record( this, caller );
    102102        }
    103103
    104104        static inline void unlock( __spinlock_t & this ) {
     105                enable_interrupts_noPoll();
    105106                __atomic_clear( &this.lock, __ATOMIC_RELEASE );
    106                 enable_interrupts_noPoll();
    107107        }
    108108
     
    139139        }
    140140
    141         static inline bool post(__bin_sem_t & this) with( this ) {
     141        static inline void post(__bin_sem_t & this) with( this ) {
     142                verify(__cfaabi_dbg_in_kernel());
     143
    142144                pthread_mutex_lock(&lock);
    143145                        bool needs_signal = !signaled;
     
    145147                pthread_mutex_unlock(&lock);
    146148
    147                 if (needs_signal) pthread_cond_signal(&cond);
    148 
    149                 return needs_signal;
     149                if (needs_signal)
     150                        pthread_cond_signal(&cond);
    150151        }
    151152#endif
Note: See TracChangeset for help on using the changeset viewer.