Changeset 7bd23ce


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

Tentative fix to sleep.cfa make it more robust

Location:
tests/concurrent
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/.expect/sleep.txt

    rab388c5 r7bd23ce  
    11start
    2 fast loop 0.047
    3 fast loop 0.094
    4 fast loop 0.141
    5 fast loop 0.188
    6 fast loop 0.235
    7 slow loop 0.277
    8 fast loop 0.282
    9 fast loop 0.329
    10 fast loop 0.376
    11 fast loop 0.423
    12 fast loop 0.47
    13 fast loop 0.517
    14 slow loop 0.554
    15 fast loop 0.564
    16 fast loop 0.611
    17 fast loop 0.658
    18 fast loop 0.705
    19 fast loop 0.752
    20 fast loop 0.799
    21 slow loop 0.831
    22 fast loop 0.846
    23 fast loop 0.893
    24 fast loop 0.94
    25 slow loop 1.108
    262done
  • 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.