Changes in / [a3cadfc:180f249]
- Files:
-
- 11 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/Makefile.am
ra3cadfc r180f249 197 197 $(srcdir)/fixcsv.sh $@ 198 198 199 # use --no-print-directory to generate csv appropriately 200 mutexStmt.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 199 216 schedint.csv: 200 217 echo "building $@" … … 355 372 chmod a+x a.out 356 373 374 mutexStmt$(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 387 mutexStmt-lock1$(EXEEXT): 388 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/lock1.cfa 389 390 mutexStmt-lock2$(EXEEXT): 391 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/lock2.cfa 392 393 mutexStmt-lock4$(EXEEXT): 394 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/lock4.cfa 395 396 mutexStmt-lock8$(EXEEXT): 397 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/lock8.cfa 398 399 mutexStmt-monitor1$(EXEEXT): 400 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/monitor1.cfa 401 402 mutexStmt-monitor2$(EXEEXT): 403 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/monitor2.cfa 404 405 mutexStmt-monitor4$(EXEEXT): 406 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/monitor4.cfa 407 408 mutexStmt-no-stmt-lock1$(EXEEXT): 409 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/no_stmt_lock1.cfa 410 411 mutexStmt-no-stmt-lock2$(EXEEXT): 412 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/no_stmt_lock2.cfa 413 414 mutexStmt-no-stmt-lock4$(EXEEXT): 415 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/no_stmt_lock4.cfa 416 417 mutexStmt-no-stmt-lock8$(EXEEXT): 418 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/mutexStmt/no_stmt_lock8.cfa 419 357 420 ## ========================================================================================================= 358 421 -
libcfa/src/concurrency/locks.hfa
ra3cadfc r180f249 324 324 } 325 325 326 // linear backoff bounded by spin_count327 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 times338 yield_counter++;339 yield();340 } else { break; }341 }342 343 // block until signalled344 while (block(this)) if(try_lock_contention(this)) return true;345 346 // this should never be reached as block(this) always returns true347 return false;348 }349 350 static inline bool lock_improved(linear_backoff_then_block_lock & this) with(this) {351 // if owner just return352 if (active_thread() == owner) return true;353 size_t compare_val = 0;354 int spin = spin_start;355 // linear backoff356 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_count366 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 times379 yield_counter++;380 yield();381 } else { break; }382 }383 384 326 if(2 != compare_val && try_lock_contention(this)) return true; 385 327 // block until signalled … … 402 344 static inline void on_notify(linear_backoff_then_block_lock & this, struct thread$ * t ) { unpark(t); } 403 345 static 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); }346 static inline void on_wakeup(linear_backoff_then_block_lock & this, size_t recursion ) { lock(this); } 405 347 406 348 //----------------------------------------------------------------------------- -
libcfa/src/concurrency/mutex_stmt.hfa
ra3cadfc r180f249 40 40 } 41 41 } 42 43 static inline L * __get_pointer( L & lock ) {44 return &lock;45 }46 42 } -
src/Concurrency/Keywords.cc
ra3cadfc r180f249 1208 1208 new ListInit( 1209 1209 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 ) ); 1214 1211 }) 1215 1212 ) -
tests/concurrent/mutexstmt/locks.cfa
ra3cadfc r180f249 4 4 const unsigned int num_times = 10000; 5 5 6 owner_lock m1, m2, m3, m4, m5;6 single_acquisition_lock m1, m2, m3, m4, m5; 7 7 8 8 thread T_Mutex {}; … … 65 65 printf("Start Test: single lock mutual exclusion\n"); 66 66 { 67 T_Mutex t[1 ];67 T_Mutex t[10]; 68 68 } 69 69 printf("End Test: single lock mutual exclusion\n");
Note: See TracChangeset
for help on using the changeset viewer.