Ignore:
Timestamp:
May 27, 2021, 2:39:35 PM (12 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr
Children:
cece53c
Parents:
ab388c5
Message:

Tentative fix to sleep.cfa make it more robust

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/sleep.cfa

    rab388c5 r7bd23ce  
    77}
    88
     9volatile int counter = 0;
     10
    911thread fast_sleeper {};
    1012void main(fast_sleeper &) {
     
    1214        for(i; 20) {
    1315                sleep(wait);
    14                 sout | acquire | "fast loop" | ((1 + i) * wait);
     16                __atomic_fetch_add( &counter, 1, __ATOMIC_RELAXED );
    1517        }
    1618}
     
    2022        Duration wait = 277`ms;
    2123        for(i; 4) {
    22 
    2324                sleep(wait);
    24                 sout | acquire | "slow loop" | ((1 + i) * wait);
     25                int val = __atomic_add_fetch( &counter, -5, __ATOMIC_RELAXED );
     26                if(val < -9) abort | "Value reached negative value:" | val;
    2527        }
    2628}
Note: See TracChangeset for help on using the changeset viewer.