Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/readyQ/rq_bench.hfa

    r2c7eee0 r0b84b15  
    6666
    6767void ^?{}( BenchCluster & this ) {
    68         adelete( this.procs );
     68        adelete( this.nprocs, this.procs );
    6969        ^(this.cl){};
    7070}
     
    8787        }
    8888}
    89 
    90 struct bench_sem {
    91         struct $thread * volatile ptr;
    92 };
    93 
    94 static inline {
    95         void  ?{}(bench_sem & this) {
    96                 this.ptr = 0p;
    97         }
    98 
    99         void ^?{}(bench_sem & this) {}
    100 
    101         bool wait(bench_sem & this) {
    102                 for() {
    103                         struct $thread * expected = this.ptr;
    104                         if(expected == 1p) {
    105                                 if(__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    106                                         return false;
    107                                 }
    108                         }
    109                         else {
    110                                 /* paranoid */ verify( expected == 0p );
    111                                 if(__atomic_compare_exchange_n(&this.ptr, &expected, active_thread(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    112                                         park();
    113                                         return true;
    114                                 }
    115                         }
    116 
    117                 }
    118         }
    119 
    120         bool post(bench_sem & this) {
    121                 for() {
    122                         struct $thread * expected = this.ptr;
    123                         if(expected == 1p) return false;
    124                         if(expected == 0p) {
    125                                 if(__atomic_compare_exchange_n(&this.ptr, &expected, 1p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    126                                         return false;
    127                                 }
    128                         }
    129                         else {
    130                                 if(__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    131                                         unpark( expected );
    132                                         return true;
    133                                 }
    134                         }
    135                 }
    136         }
    137 }
Note: See TracChangeset for help on using the changeset viewer.