Changes in / [a3cadfc:180f249]


Ignore:
Files:
11 added
5 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.am

    ra3cadfc r180f249  
    197197        $(srcdir)/fixcsv.sh $@
    198198
     199# use --no-print-directory to generate csv appropriately
     200mutexStmt.csv:
     201        echo "building $@"
     202        echo "1-lock,2-lock,4-lock,8-lock,1-no-stmt-lock,2-no-stmt-lock,4-no-stmt-lock,8-no-stmt-lock,1-monitor,2-monitor,4-monitor" > $@
     203        +make mutexStmt-lock1.runquiet >> $@ && echo -n ',' >> $@
     204        +make mutexStmt-lock2.runquiet >> $@ && echo -n ',' >> $@
     205        +make mutexStmt-lock4.runquiet >> $@ && echo -n ',' >> $@
     206        +make mutexStmt-lock8.runquiet >> $@ && echo -n ',' >> $@
     207        +make mutexStmt-no-stmt-lock1.runquiet >> $@ && echo -n ',' >> $@
     208        +make mutexStmt-no-stmt-lock2.runquiet >> $@ && echo -n ',' >> $@
     209        +make mutexStmt-no-stmt-lock4.runquiet >> $@ && echo -n ',' >> $@
     210        +make mutexStmt-no-stmt-lock8.runquiet >> $@ && echo -n ',' >> $@
     211        +make mutexStmt-monitor1.runquiet >> $@ && echo -n ',' >> $@
     212        +make mutexStmt-monitor2.runquiet >> $@ && echo -n ',' >> $@
     213        +make mutexStmt-monitor4.runquiet >> $@
     214        $(srcdir)/fixcsv.sh $@
     215
    199216schedint.csv:
    200217        echo "building $@"
     
    355372        chmod a+x a.out
    356373
     374mutexStmt$(EXEEXT) :                \
     375        mutexStmt-lock1.run                 \
     376        mutexStmt-lock2.run                 \
     377        mutexStmt-lock4.run                 \
     378        mutexStmt-lock8.run                 \
     379        mutexStmt-no-stmt-lock1.run \
     380        mutexStmt-no-stmt-lock2.run \
     381        mutexStmt-no-stmt-lock4.run \
     382        mutexStmt-no-stmt-lock8.run \
     383        mutexStmt-monitor1.run      \
     384        mutexStmt-monitor2.run      \
     385        mutexStmt-monitor4.run
     386
     387mutexStmt-lock1$(EXEEXT):
     388        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/lock1.cfa
     389
     390mutexStmt-lock2$(EXEEXT):
     391        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/lock2.cfa
     392
     393mutexStmt-lock4$(EXEEXT):
     394        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/lock4.cfa
     395
     396mutexStmt-lock8$(EXEEXT):
     397        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/lock8.cfa
     398
     399mutexStmt-monitor1$(EXEEXT):
     400        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/monitor1.cfa
     401
     402mutexStmt-monitor2$(EXEEXT):
     403        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/monitor2.cfa
     404
     405mutexStmt-monitor4$(EXEEXT):
     406        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/monitor4.cfa
     407
     408mutexStmt-no-stmt-lock1$(EXEEXT):
     409        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/no_stmt_lock1.cfa
     410
     411mutexStmt-no-stmt-lock2$(EXEEXT):
     412        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/no_stmt_lock2.cfa
     413
     414mutexStmt-no-stmt-lock4$(EXEEXT):
     415        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/no_stmt_lock4.cfa
     416
     417mutexStmt-no-stmt-lock8$(EXEEXT):
     418        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/no_stmt_lock8.cfa
     419
    357420## =========================================================================================================
    358421
  • libcfa/src/concurrency/locks.hfa

    ra3cadfc r180f249  
    324324        }
    325325
    326         // linear backoff bounded by spin_count
    327         spin = spin_start;
    328         int spin_counter = 0;
    329         int yield_counter = 0;
    330         for ( ;; ) {
    331                 if(try_lock_contention(this)) return true;
    332                 if(spin_counter < spin_count) {
    333                         for (int i = 0; i < spin; i++) Pause();
    334                         if (spin < spin_end) spin += spin;
    335                         else spin_counter++;
    336                 } else if (yield_counter < yield_count) {
    337                         // after linear backoff yield yield_count times
    338                         yield_counter++;
    339                         yield();
    340                 } else { break; }
    341         }
    342 
    343         // block until signalled
    344         while (block(this)) if(try_lock_contention(this)) return true;
    345 
    346         // this should never be reached as block(this) always returns true
    347         return false;
    348 }
    349 
    350 static inline bool lock_improved(linear_backoff_then_block_lock & this) with(this) {
    351         // if owner just return
    352         if (active_thread() == owner) return true;
    353         size_t compare_val = 0;
    354         int spin = spin_start;
    355         // linear backoff
    356         for( ;; ) {
    357                 compare_val = 0;
    358                 if (internal_try_lock(this, compare_val)) return true;
    359                 if (2 == compare_val) break;
    360                 for (int i = 0; i < spin; i++) Pause();
    361                 if (spin >= spin_end) break;
    362                 spin += spin;
    363         }
    364 
    365         // linear backoff bounded by spin_count
    366         spin = spin_start;
    367         int spin_counter = 0;
    368         int yield_counter = 0;
    369         for ( ;; ) {
    370                 compare_val = 0;
    371                 if(internal_try_lock(this, compare_val)) return true;
    372                 if (2 == compare_val) break;
    373                 if(spin_counter < spin_count) {
    374                         for (int i = 0; i < spin; i++) Pause();
    375                         if (spin < spin_end) spin += spin;
    376                         else spin_counter++;
    377                 } else if (yield_counter < yield_count) {
    378                         // after linear backoff yield yield_count times
    379                         yield_counter++;
    380                         yield();
    381                 } else { break; }
    382         }
    383 
    384326        if(2 != compare_val && try_lock_contention(this)) return true;
    385327        // block until signalled
     
    402344static inline void on_notify(linear_backoff_then_block_lock & this, struct thread$ * t ) { unpark(t); }
    403345static inline size_t on_wait(linear_backoff_then_block_lock & this) { unlock(this); return 0; }
    404 static inline void on_wakeup(linear_backoff_then_block_lock & this, size_t recursion ) { lock_improved(this); }
     346static inline void on_wakeup(linear_backoff_then_block_lock & this, size_t recursion ) { lock(this); }
    405347
    406348//-----------------------------------------------------------------------------
  • libcfa/src/concurrency/mutex_stmt.hfa

    ra3cadfc r180f249  
    4040        }
    4141    }
    42 
    43     static inline L * __get_pointer( L & lock ) {
    44         return &lock;
    45     }
    4642}
  • src/Concurrency/Keywords.cc

    ra3cadfc r180f249  
    12081208                        new ListInit(
    12091209                                map_range < std::list<Initializer*> > ( args, [](Expression * var ){
    1210                                         return new SingleInit( new UntypedExpr(
    1211                                                 new NameExpr( "__get_pointer" ),
    1212                                                 { var }
    1213                                         ) );
     1210                                        return new SingleInit( new AddressExpr( var ) );
    12141211                                })
    12151212                        )
  • tests/concurrent/mutexstmt/locks.cfa

    ra3cadfc r180f249  
    44const unsigned int num_times = 10000;
    55
    6 owner_lock m1, m2, m3, m4, m5;
     6single_acquisition_lock m1, m2, m3, m4, m5;
    77
    88thread T_Mutex {};
     
    6565        printf("Start Test: single lock mutual exclusion\n");
    6666        {
    67                 T_Mutex t[1];
     67                T_Mutex t[10];
    6868        }
    6969        printf("End Test: single lock mutual exclusion\n");
Note: See TracChangeset for help on using the changeset viewer.