Changeset 34c6c767 for src/libcfa


Ignore:
Timestamp:
Nov 9, 2017, 2:01:44 PM (6 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:
65d6de4, 6d2386e
Parents:
ea7d2b0
Message:

Added CFA_LOCK_NO_YIELD to toggle yielding when locking for performance measuring

File:
1 edited

Legend:

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

    rea7d2b0 r34c6c767  
    5454static inline __lock_size_t aggregate    ( monitor_desc * storage [], const __waitfor_mask_t & mask );
    5555
     56#ifndef __CFA_LOCK_NO_YIELD
     57#define DO_LOCK lock_yield
     58#else
     59#define DO_LOCK lock
     60#endif
     61
    5662//-----------------------------------------------------------------------------
    5763// Useful defines
     
    8490        // Enter single monitor
    8591        static void __enter_monitor_desc( monitor_desc * this, const __monitor_group_t & group ) {
    86                 // Lock the monitor spinlock, lock_yield to reduce contention
    87                 lock_yield( this->lock DEBUG_CTX2 );
     92                // Lock the monitor spinlock
     93                DO_LOCK( this->lock DEBUG_CTX2 );
    8894                thread_desc * thrd = this_thread;
    8995
     
    132138
    133139        static void __enter_monitor_dtor( monitor_desc * this, fptr_t func ) {
    134                 // Lock the monitor spinlock, lock_yield to reduce contention
    135                 lock_yield( this->lock DEBUG_CTX2 );
     140                // Lock the monitor spinlock
     141                DO_LOCK( this->lock DEBUG_CTX2 );
    136142                thread_desc * thrd = this_thread;
    137143
     
    196202        // Leave single monitor
    197203        void __leave_monitor_desc( monitor_desc * this ) {
    198                 // Lock the monitor spinlock, lock_yield to reduce contention
    199                 lock_yield( this->lock DEBUG_CTX2 );
     204                // Lock the monitor spinlock, DO_LOCK to reduce contention
     205                DO_LOCK( this->lock DEBUG_CTX2 );
    200206
    201207                LIB_DEBUG_PRINT_SAFE("Kernel : %10p Leaving mon %p (%p)\n", this_thread, this, this->owner);
     
    243249
    244250                // Lock the monitor now
    245                 lock_yield( this->lock DEBUG_CTX2 );
     251                DO_LOCK( this->lock DEBUG_CTX2 );
    246252
    247253                disable_interrupts();
     
    732738static inline void lock_all( __spinlock_t * locks [], __lock_size_t count ) {
    733739        for( __lock_size_t i = 0; i < count; i++ ) {
    734                 lock_yield( *locks[i] DEBUG_CTX2 );
     740                DO_LOCK( *locks[i] DEBUG_CTX2 );
    735741        }
    736742}
     
    739745        for( __lock_size_t i = 0; i < count; i++ ) {
    740746                __spinlock_t * l = &source[i]->lock;
    741                 lock_yield( *l DEBUG_CTX2 );
     747                DO_LOCK( *l DEBUG_CTX2 );
    742748                if(locks) locks[i] = l;
    743749        }
Note: See TracChangeset for help on using the changeset viewer.