- Timestamp:
- Dec 8, 2025, 11:29:33 AM (2 months ago)
- Branches:
- master, stuck-waitfor-destruct
- Children:
- 79ba50c
- Parents:
- 8f448e0 (diff), 79ec8c3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- tests
- Files:
-
- 14 edited
- 1 moved
-
concurrency/barrier/generation.cfa (modified) (2 diffs)
-
concurrency/barrier/last.cfa (modified) (2 diffs)
-
concurrency/barrier/order.cfa (modified) (2 diffs)
-
concurrency/examples/boundedBufferTHREAD.cfa (modified) (4 diffs)
-
concurrency/examples/datingService.cfa (modified) (3 diffs)
-
concurrency/futures/.expect/multi.txt.off (moved) (moved from tests/concurrency/futures/.expect/multi.txt )
-
concurrency/futures/multi.cfa (modified) (1 diff)
-
concurrency/futures/select_future.cfa (modified) (1 diff)
-
concurrency/futures/typed.cfa (modified) (5 diffs)
-
concurrency/once.cfa (modified) (1 diff)
-
concurrency/readyQ/barrier_sleeper.cfa (modified) (1 diff)
-
concurrency/signal/block.cfa (modified) (1 diff)
-
concurrency/waituntil/futures.cfa (modified) (2 diffs)
-
io/comp_basic.cfa (modified) (1 diff)
-
io/comp_fair.cfa (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrency/barrier/generation.cfa
r8f448e0 r5e0b6657 20 20 unsigned NUM_LAPS = 53; 21 21 22 #include < concurrency/barrier.hfa>22 #include <barrier.hfa> 23 23 #include <fstream.hfa> 24 24 #include <mutex_stmt.hfa> … … 45 45 46 46 // Block on the barrier 47 block( bar);47 block( bar ); 48 48 } 49 49 } -
tests/concurrency/barrier/last.cfa
r8f448e0 r5e0b6657 17 17 // function is called at the appropriate time. 18 18 19 #include < concurrency/barrier.hfa>19 #include <barrier.hfa> 20 20 #include <fstream.hfa> 21 21 #include <mutex_stmt.hfa> … … 34 34 volatile unsigned validate_calls = 0; 35 35 36 void validate( ) {36 void validate(...) { 37 37 unsigned vc = validate_calls; 38 38 unsigned expected = generation[0]; -
tests/concurrency/barrier/order.cfa
r8f448e0 r5e0b6657 10 10 // Created On : Fri Apr 01 11:39:09 2022 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Nov 10 11:22:56 202413 // Update Count : 2 012 // Last Modified On : Mon Oct 27 22:44:36 2025 13 // Update Count : 22 14 14 // 15 15 … … 24 24 25 25 volatile unsigned generation = 0; // count laps 26 void last( ) {26 void last( ... ) { 27 27 generation += 1; // last thread at barrier advances 28 28 } -
tests/concurrency/examples/boundedBufferTHREAD.cfa
r8f448e0 r5e0b6657 10 10 // Created On : Wed Apr 18 22:52:12 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 16 23:09:43 202013 // Update Count : 2 512 // Last Modified On : Wed Nov 5 08:05:24 2025 13 // Update Count : 28 14 14 // 15 15 16 #include <stdlib.hfa> // random17 16 #include <fstream.hfa> 18 17 #include <kernel.hfa> … … 65 64 void main( Producer & prod ) with( prod ) { 66 65 for ( i; 1 ~= N ) { 67 yield( random( 5 ) );66 yield( prng( 5 ) ); 68 67 insert( buffer, 1 ); 69 68 } // for … … 81 80 sum = 0; 82 81 for () { 83 yield( random( 5 ) );82 yield( prng( 5 ) ); 84 83 int item = remove( buffer ); 85 84 if ( item == Sentinel ) break; // sentinel ? … … 101 100 processor p; 102 101 103 //srandom( getpid() ); 104 srandom( 1003 ); 102 set_seed( 1003 ); 105 103 106 104 for ( i; Cons ) { // create consumers 107 cons[i] = new( &buffer, sums[i] ); 105 cons[i] = new( &buffer, sums[i] ); // NEW CANNOT HANDLE BUFFER REFERENCE 108 106 } // for 109 107 for ( i; Prods ) { // create producers -
tests/concurrency/examples/datingService.cfa
r8f448e0 r5e0b6657 10 10 // Created On : Mon Oct 30 12:56:20 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Sep 27 15:42:25 202013 // Update Count : 4 012 // Last Modified On : Tue Nov 4 21:58:29 2025 13 // Update Count : 41 14 14 // 15 15 … … 28 28 29 29 unsigned int girl( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) with( ds ) { 30 if ( is_empty( Boys[ccode] ) ) {// no compatible boy ?30 if ( empty( Boys[ccode] ) ) { // no compatible boy ? 31 31 wait( Girls[ccode] ); // wait for boy 32 32 GirlPhoneNo = PhoneNo; // make phone number available … … 40 40 41 41 unsigned int boy( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) with( ds ) { 42 if ( is_empty( Girls[ccode] ) ) {// no compatible girl ?42 if ( empty( Girls[ccode] ) ) { // no compatible girl ? 43 43 wait( Boys[ccode] ); // wait for girl 44 44 BoyPhoneNo = PhoneNo; // make phone number available -
tests/concurrency/futures/multi.cfa
r8f448e0 r5e0b6657 1 // DEPRECATED future type multi_future. Eventually remove this test. 2 1 3 #include <thread.hfa> 2 4 #include <future.hfa> -
tests/concurrency/futures/select_future.cfa
r8f448e0 r5e0b6657 1 1 #include <thread.hfa> 2 2 #include <future.hfa> 3 #include < concurrency/barrier.hfa>3 #include <barrier.hfa> 4 4 5 5 enum {NFUTURES = 10}; -
tests/concurrency/futures/typed.cfa
r8f448e0 r5e0b6657 8 8 }; 9 9 10 void ?{}( Server & this) {11 this.cnt = 0;12 for (i; NFUTURES) {13 this.requests[i] = 0p;10 void ?{}( Server & server ) with( server ) { 11 cnt = 0; 12 for ( i; NFUTURES ) { 13 requests[i] = 0p; 14 14 } 15 15 } 16 16 17 void ^?{}( Server & mutex this ){18 assert( this.cnt == 0);19 for (i; NFUTURES) {20 this.requests[i] = 0p;17 void ^?{}( Server & mutex server ) with( server ) { 18 assert( cnt == 0 ); 19 for ( i; NFUTURES ) { 20 requests[i] = 0p; 21 21 } 22 22 } 23 23 24 void process( Server & this, int i ){25 if( this.requests[i] == 0p ) return;26 single_future(int) * f = this.requests[i];27 this.requests[i] = 0p;28 this.cnt--;29 fulfil( *f , i);24 void process( Server & server, int i ) with( server ) { 25 if ( requests[i] == 0p ) return; 26 single_future(int) * f = requests[i]; 27 requests[i] = 0p; 28 cnt--; 29 (*f)( i ); // fulfil 30 30 } 31 31 32 void call( Server & mutex this, single_future(int) & f) {33 for (i; NFUTURES) {34 if ( this.requests[i] == 0p ) {35 this.requests[i] = &f;36 this.cnt++;32 void call( Server & mutex server, single_future(int) & f ) with( server ) { 33 for ( i; NFUTURES ) { 34 if ( requests[i] == 0p ) { 35 requests[i] = &f; 36 cnt++; 37 37 return; 38 38 } … … 41 41 } 42 42 43 void main( Server & this) {43 void main( Server & server ) { 44 44 unsigned i = 0; 45 for () {46 waitfor ( ^?{} : this) {45 for () { 46 waitfor ( ^?{} : server ) { 47 47 break; 48 } 49 or when( this.cnt < NFUTURES ) waitfor( call: this ) {} 48 } or when( server.cnt < NFUTURES ) waitfor( call : server ) {} 50 49 or else { 51 process( this, i % NFUTURES );50 process( server, i % NFUTURES ); 52 51 i++; 53 52 } 54 53 } 55 54 56 for (i; NFUTURES) {57 process( this, i );55 for ( i; NFUTURES ) { 56 process( server, i ); 58 57 } 59 58 } … … 62 61 thread Worker {}; 63 62 64 void thrash( void) {63 void thrash() { 65 64 volatile int locals[250]; 66 for (i; 250) {65 for ( i; 250 ) { 67 66 locals[i] = 0xdeadbeef; 68 67 } 69 68 } 70 69 71 void work( void) {70 void work() { 72 71 single_future(int) mine; 73 72 call( *the_server, mine ); 74 wait( mine );73 mine(); // get 75 74 } 76 75 77 76 void main( Worker & ) { 78 for (150) {77 for ( 150 ) { 79 78 thrash(); 80 79 work(); … … 84 83 85 84 int main() { 86 printf( "start\n" ); // non-empty .expect file85 printf( "start\n" ); // non-empty .expect file 87 86 processor procs[2]; 88 87 { … … 93 92 } 94 93 } 95 printf( "done\n" ); // non-empty .expect file 96 94 printf( "done\n" ); // non-empty .expect file 97 95 } -
tests/concurrency/once.cfa
r8f448e0 r5e0b6657 9 9 volatile int check; 10 10 11 void reset( ) {11 void reset( ... ) { 12 12 (global){}; 13 13 check = 0; -
tests/concurrency/readyQ/barrier_sleeper.cfa
r8f448e0 r5e0b6657 17 17 // Processors and thread are removed in an interleaved fashion for a weirder case. 18 18 19 #include < concurrency/barrier.hfa>19 #include <barrier.hfa> 20 20 #include <fstream.hfa> 21 21 #include <time.hfa> -
tests/concurrency/signal/block.cfa
r8f448e0 r5e0b6657 80 80 [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = active_thread(); 81 81 82 if( ! is_empty( cond ) ) {82 if( ! empty( cond ) ) { 83 83 84 84 thread$ * next = ( thread$ * ) front( cond ); -
tests/concurrency/waituntil/futures.cfa
r8f448e0 r5e0b6657 1 #include < select.hfa>1 #include <fstream.hfa> 2 2 #include <future.hfa> 3 3 #include <thread.hfa> … … 5 5 future(int) A, B, C; 6 6 7 semaphore s{0}; 8 9 thread Server1 {}; 10 void main( Server1 & ) { 11 fulfil(B, 3); 12 P( s ); 13 fulfil(A, 2); 14 fulfil(C, 4); 15 } 16 17 thread Server2 {}; 18 void main( Server2 & ) { 19 fulfil(B, 6); 20 fulfil(A, 5); 21 fulfil(C, 7); 7 thread Server {}; 8 void main( Server & ) { 9 B( 3 ); // fulfil( B, 3 ); 10 A( 2 ); 11 C( 4 ); 22 12 } 23 13 24 14 int main() { 25 processor proc[1]; 26 printf("start\n"); // currently not working 27 { 28 Server1 s1; 29 waituntil( A ) { get(A); } 30 or waituntil( B ) { get(B); V( s ); } 31 and waituntil( C ) { get(C); } 32 } 33 reset(A); 34 reset(B); 35 reset(C); 36 for ( int i = 0; i < 8; i++ ) { 37 { 38 Server2 s2; 39 when( i % 2 == 0 ) waituntil( A ) { get(A); } 40 or when( i % 4 < 2 ) waituntil( B ) { get(B); } 41 and when( i < 4 ) waituntil( C ) { get(C); } 42 } 43 reset(A); 44 reset(B); 45 reset(C); 46 { 47 Server2 s2; 48 ( 49 when( i % 2 == 0 ) waituntil( A ) { get(A); } 50 or when( i % 4 < 2 ) waituntil( B ) { get(B); } 51 ) 52 and when( i < 4 ) waituntil( C ) { get(C); } 53 } 54 reset(A); 55 reset(B); 56 reset(C); 57 } 58 59 printf("end\n"); 60 return 0; 15 processor p; 16 sout | "start"; 17 { 18 size_t count = 0; 19 Server s; 20 for ( ; count < 3; ) { 21 waituntil( A ) { count += 1; A(); /* get( A ) */ } 22 or waituntil( B ) { count += 1; B(); } 23 or waituntil( C ) { count += 1; C(); } 24 } 25 reset( A ); reset( B ); reset( C ); 26 } 27 { 28 size_t count = 0; 29 Server s; 30 for ( ; count < 3; ) { 31 waituntil( A ) { count += 1; A(); /* get( A ) */ } 32 or waituntil( B ) { count += 1; B(); } 33 and waituntil( C ) { count += 1; C(); } 34 } 35 reset( A ); reset( B ); reset( C ); 36 } 37 size_t count = 0; 38 for ( i; 8 ) { 39 { 40 Server s; 41 when( i % 2 == 0 ) waituntil( A ) { count += 1; A(); } 42 or when( i % 4 < 2 ) waituntil( B ) { count += 1; B(); } 43 and when( i < 4 ) waituntil( C ) { count += 1; C(); } 44 } 45 reset( A ); reset( B ); reset( C ); 46 { 47 Server s; 48 ( when( i % 2 == 0 ) waituntil( A ) { count += 1; A(); } 49 or when( i % 4 < 2 ) waituntil( B ) { count += 1; B(); } 50 ) and when( i < 4 ) waituntil( C ) { count += 1; C(); } 51 } 52 reset( A ); reset( B ); reset( C ); 53 } // for 54 sout | "end"; 61 55 } -
tests/io/comp_basic.cfa
r8f448e0 r5e0b6657 16 16 17 17 18 #include < concurrency/barrier.hfa>18 #include <barrier.hfa> 19 19 #include <fstream.hfa> 20 20 #include <iofwd.hfa> -
tests/io/comp_fair.cfa
r8f448e0 r5e0b6657 16 16 17 17 18 #include < concurrency/barrier.hfa>18 #include <barrier.hfa> 19 19 #include <fstream.hfa> 20 20 #include <iofwd.hfa>
Note:
See TracChangeset
for help on using the changeset viewer.