Changeset a882b68 for tests


Ignore:
Timestamp:
May 4, 2023, 2:39:52 PM (20 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
dd7a8ce
Parents:
cb69fba
Message:

added a test change to help locate the deadlock on next test failure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/waituntil/channels.cfa

    rcb69fba ra882b68  
    1212    long long int a, b, c, i = 0, myTotal = 0;
    1313    for( ;;i++ ) {
    14         when( i % 2 == 0 ) waituntil( (a << A) ) { myTotal += a; }
    15         or when( i % 4 < 2 ) waituntil( (b << B) ) { myTotal += b; }
    16         or waituntil( (c << C) ) { if ( c == -1 ) break; myTotal += c; }
     14        when( i % 2 == 0 ) waituntil( a << A ) { myTotal += a; }
     15        or when( i % 4 < 2 ) waituntil( b << B ) { myTotal += b; }
     16        or waituntil( c << C ) { if ( c == -1 ) break; myTotal += c; }
    1717        or when( i % 8 < 4 ) else {}
    1818    }
     
    2222thread Drainer {}; // ensures that the changing when states of Server1 don't result in a deadlock
    2323void main( Drainer & this ) {
    24     long long int a, b, c, i = 0, myTotal = 0;
    25     for( ;;i++ ) {
    26         waituntil( (a << A) ) { myTotal += a; }
    27         or waituntil( (b << B) ) { myTotal += b; }
    28         or waituntil( (c << C) ) { if ( c == -1 ) break; myTotal += c; }
     24    long long int a, b, c, myTotal = 0;
     25    for( ;; ) {
     26        waituntil( a << A ) { myTotal += a; }
     27        or waituntil( b << B ) { myTotal += b; }
     28        or waituntil( c << C ) { if ( c == -1 ) break; myTotal += c; }
     29        or else {}
    2930    }
    3031    __atomic_fetch_add( &globalTotal, myTotal, __ATOMIC_SEQ_CST );
     
    3940        try_insert( B, 0 );
    4041        try_insert( C, 0 );
    41         [out, success] = try_remove(A);
     42        [out, success] = try_remove( A );
    4243        if ( success ) myTotal += out;
    43         [out, success] = try_remove(B);
     44        [out, success] = try_remove( B );
    4445        if ( success ) myTotal += out;
    45         [out, success] = try_remove(C);
     46        [out, success] = try_remove( C );
    4647        if ( success ) myTotal += out;
    4748    }
     
    6869            Churner c;
    6970            for( long long int j = 0; j < numtimes; j++ ) {
    70                 when( j % 2 == 0 ) waituntil( (j >> A) ) { total += j; }
    71                 or when( j % 4 < 2 ) waituntil( (j >> B) ) { total += j; }
    72                 and when( j % 8 < 4 ) waituntil( (j >> C) ) { total += j; }
     71                when( j % 2 == 0 ) waituntil( j >> A ) { total += j; }
     72                or when( j % 4 < 2 ) waituntil( j >> B ) { total += j; }
     73                and when( j % 8 < 4 ) waituntil( j >> C ) { total += j; }
    7374            }
    7475            done = true;
     
    7677        }
    7778        printf("waiting for empty channels\n");
    78         while( get_count(A) > 0 || get_count(B) > 0 || get_count(C) > 0 ) { Pause(); }
     79        while( get_count( A ) > 0 || get_count( B ) > 0 || get_count( C ) > 0 ) { }
    7980        printf("sending sentinels\n");
    8081        for ( i; numServers + 1 ) insert( C, -1 );
Note: See TracChangeset for help on using the changeset viewer.