ADTast-experimental
Last change
on this file since 94672ba was
7b53bfd,
checked in by caparsons <caparson@…>, 17 months ago
|
Eliminating the busy wait spin at the end seems to resolve deadlock. Added further tests to try and narrow down failure case, and to see if the failure is waituntil specific
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[b5513f1] | 1 | #include <select.hfa> |
---|
| 2 | #include <thread.hfa> |
---|
| 3 | #include <channel.hfa> |
---|
| 4 | |
---|
| 5 | channel(long long int) C; |
---|
| 6 | |
---|
| 7 | volatile bool done = false; |
---|
| 8 | long long int globalTotal = 0; |
---|
| 9 | |
---|
| 10 | thread Server1 {}; |
---|
| 11 | void main( Server1 & this ) { |
---|
| 12 | long long int c, i = 0, myTotal = 0; |
---|
| 13 | for( ;;i++ ) { |
---|
| 14 | waituntil( c << C ) { if ( c == -1 ) break; myTotal += c; } |
---|
| 15 | } |
---|
| 16 | __atomic_fetch_add( &globalTotal, myTotal, __ATOMIC_SEQ_CST ); |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | size_t numtimes = 100000; |
---|
| 20 | size_t numServers = 1; |
---|
| 21 | int main( int argc, char * argv[] ) { |
---|
| 22 | if ( argc == 2 ) |
---|
| 23 | numtimes = atoi( argv[1] ); |
---|
| 24 | |
---|
| 25 | processor p[numServers]; |
---|
| 26 | C{5}; |
---|
| 27 | |
---|
| 28 | long long int total = 0; |
---|
| 29 | printf("start\n"); |
---|
[e50fce1] | 30 | volatile size_t LINE_COUNTER = 1; |
---|
[b5513f1] | 31 | { |
---|
| 32 | Server1 s[numServers]; |
---|
| 33 | for( long long int j = 0; j < numtimes; j++ ) { |
---|
| 34 | waituntil( j >> C ) { total += j; } |
---|
| 35 | } |
---|
[e50fce1] | 36 | LINE_COUNTER = 2; |
---|
[b5513f1] | 37 | printf("waiting for empty channels\n"); |
---|
[e50fce1] | 38 | LINE_COUNTER = 3; |
---|
[c34a1a4] | 39 | // size_t C_count = get_count( C ); |
---|
| 40 | // LINE_COUNTER = 5; |
---|
| 41 | // while( C_count > 0 ) { |
---|
| 42 | // C_count = get_count( C ); |
---|
| 43 | // } |
---|
[253a78f] | 44 | LINE_COUNTER = 7; |
---|
[b5513f1] | 45 | printf("sending sentinels\n"); |
---|
[253a78f] | 46 | LINE_COUNTER = 11; |
---|
[b5513f1] | 47 | for ( i; numServers ) insert( C, -1 ); |
---|
[253a78f] | 48 | LINE_COUNTER = 13; |
---|
[b5513f1] | 49 | printf("joining servers\n"); |
---|
[253a78f] | 50 | LINE_COUNTER = 17; |
---|
[b5513f1] | 51 | } |
---|
[7b53bfd] | 52 | assert(get_count( C ) == 0); |
---|
[253a78f] | 53 | LINE_COUNTER = 19; |
---|
[b5513f1] | 54 | if ( total != globalTotal ) |
---|
| 55 | printf("CHECKSUM MISMATCH!! Main thread got %lld, server sum is %lld\n", total, globalTotal); |
---|
| 56 | printf("done\n"); |
---|
| 57 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.