Changeset 5e0b6657 for tests


Ignore:
Timestamp:
Dec 8, 2025, 11:29:33 AM (2 months ago)
Author:
Michael Brooks <mlbrooks@…>
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.
Message:

Merge remote-tracking branch 'refs/remotes/origin/master'

Location:
tests
Files:
14 edited
1 moved

Legend:

Unmodified
Added
Removed
  • tests/concurrency/barrier/generation.cfa

    r8f448e0 r5e0b6657  
    2020unsigned NUM_LAPS = 53;
    2121
    22 #include <concurrency/barrier.hfa>
     22#include <barrier.hfa>
    2323#include <fstream.hfa>
    2424#include <mutex_stmt.hfa>
     
    4545
    4646                        // Block on the barrier
    47                         block(bar);
     47                        block( bar );
    4848                }
    4949}
  • tests/concurrency/barrier/last.cfa

    r8f448e0 r5e0b6657  
    1717// function is called at the appropriate time.
    1818
    19 #include <concurrency/barrier.hfa>
     19#include <barrier.hfa>
    2020#include <fstream.hfa>
    2121#include <mutex_stmt.hfa>
     
    3434volatile unsigned validate_calls = 0;
    3535
    36 void validate() {
     36void validate(...) {
    3737        unsigned vc = validate_calls;
    3838        unsigned expected = generation[0];
  • tests/concurrency/barrier/order.cfa

    r8f448e0 r5e0b6657  
    1010// Created On       : Fri Apr 01 11:39:09 2022
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Nov 10 11:22:56 2024
    13 // Update Count     : 20
     12// Last Modified On : Mon Oct 27 22:44:36 2025
     13// Update Count     : 22
    1414//
    1515
     
    2424
    2525volatile unsigned generation = 0;                                               // count laps
    26 void last() {
     26void last( ... ) {
    2727        generation += 1;                                                                        // last thread at barrier advances
    2828}
  • tests/concurrency/examples/boundedBufferTHREAD.cfa

    r8f448e0 r5e0b6657  
    1010// Created On       : Wed Apr 18 22:52:12 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 16 23:09:43 2020
    13 // Update Count     : 25
     12// Last Modified On : Wed Nov  5 08:05:24 2025
     13// Update Count     : 28
    1414//
    1515
    16 #include <stdlib.hfa>                                                                   // random
    1716#include <fstream.hfa>
    1817#include <kernel.hfa>
     
    6564void main( Producer & prod ) with( prod ) {
    6665        for ( i; 1 ~= N ) {
    67                 yield( random( 5 ) );
     66                yield( prng( 5 ) );
    6867                insert( buffer, 1 );
    6968        } // for
     
    8180        sum = 0;
    8281        for () {
    83                 yield( random( 5 ) );
     82                yield( prng( 5 ) );
    8483                int item = remove( buffer );
    8584          if ( item == Sentinel ) break;                                        // sentinel ?
     
    101100        processor p;
    102101
    103         //srandom( getpid() );
    104         srandom( 1003 );
     102        set_seed( 1003 );
    105103
    106104        for ( i; Cons ) {                                                                       // create consumers
    107                 cons[i] = new( &buffer, sums[i] );
     105                cons[i] = new( &buffer, sums[i] );                              // NEW CANNOT HANDLE BUFFER REFERENCE
    108106        } // for
    109107        for ( i; Prods ) {                                                                      // create producers
  • tests/concurrency/examples/datingService.cfa

    r8f448e0 r5e0b6657  
    1010// Created On       : Mon Oct 30 12:56:20 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Sep 27 15:42:25 2020
    13 // Update Count     : 40
     12// Last Modified On : Tue Nov  4 21:58:29 2025
     13// Update Count     : 41
    1414//
    1515
     
    2828
    2929unsigned 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 ?
    3131                wait( Girls[ccode] );                                                   // wait for boy
    3232                GirlPhoneNo = PhoneNo;                                                  // make phone number available
     
    4040
    4141unsigned 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 ?
    4343                wait( Boys[ccode] );                                                    // wait for girl
    4444                BoyPhoneNo = PhoneNo;                                                   // make phone number available
  • tests/concurrency/futures/multi.cfa

    r8f448e0 r5e0b6657  
     1// DEPRECATED future type multi_future. Eventually remove this test.
     2
    13#include <thread.hfa>
    24#include <future.hfa>
  • tests/concurrency/futures/select_future.cfa

    r8f448e0 r5e0b6657  
    11#include <thread.hfa>
    22#include <future.hfa>
    3 #include <concurrency/barrier.hfa>
     3#include <barrier.hfa>
    44
    55enum {NFUTURES = 10};
  • tests/concurrency/futures/typed.cfa

    r8f448e0 r5e0b6657  
    88};
    99
    10 void ?{}( Server & this ) {
    11         this.cnt = 0;
    12         for(i; NFUTURES) {
    13                 this.requests[i] = 0p;
     10void ?{}( Server & server ) with( server ) {
     11        cnt = 0;
     12        for ( i; NFUTURES ) {
     13                requests[i] = 0p;
    1414        }
    1515}
    1616
    17 void ^?{}( Server & mutex this ) {
    18         assert(this.cnt == 0);
    19         for(i; NFUTURES) {
    20                 this.requests[i] = 0p;
     17void ^?{}( Server & mutex server ) with( server ) {
     18        assert( cnt == 0 );
     19        for ( i; NFUTURES ) {
     20                requests[i] = 0p;
    2121        }
    2222}
    2323
    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);
     24void 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
    3030}
    3131
    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++;
     32void 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++;
    3737                        return;
    3838                }
     
    4141}
    4242
    43 void main( Server & this ) {
     43void main( Server & server ) {
    4444        unsigned i = 0;
    45         for() {
    46                 waitfor( ^?{} : this ) {
     45        for () {
     46                waitfor ( ^?{} : server ) {
    4747                        break;
    48                 }
    49                 or when( this.cnt < NFUTURES ) waitfor( call: this ) {}
     48                } or when( server.cnt < NFUTURES ) waitfor( call : server ) {}
    5049                or else {
    51                         process( this, i % NFUTURES );
     50                        process( server, i % NFUTURES );
    5251                        i++;
    5352                }
    5453        }
    5554
    56         for(i; NFUTURES) {
    57                 process( this, i );
     55        for ( i; NFUTURES ) {
     56                process( server, i );
    5857        }
    5958}
     
    6261thread Worker {};
    6362
    64 void thrash(void) {
     63void thrash() {
    6564        volatile int locals[250];
    66         for(i; 250) {
     65        for ( i; 250 ) {
    6766                locals[i] = 0xdeadbeef;
    6867        }
    6968}
    7069
    71 void work(void) {
     70void work() {
    7271        single_future(int) mine;
    7372        call( *the_server, mine );
    74         wait( mine );
     73        mine();                                                                                         // get
    7574}
    7675
    7776void main( Worker & ) {
    78         for(150) {
     77        for ( 150 ) {
    7978                thrash();
    8079                work();
     
    8483
    8584int main() {
    86         printf( "start\n" );                            // non-empty .expect file
     85        printf( "start\n" );                                                            // non-empty .expect file
    8786        processor procs[2];
    8887        {
     
    9392                }
    9493        }
    95         printf( "done\n" );                             // non-empty .expect file
    96 
     94        printf( "done\n" );                                                                     // non-empty .expect file
    9795}
  • tests/concurrency/once.cfa

    r8f448e0 r5e0b6657  
    99volatile int check;
    1010
    11 void reset() {
     11void reset( ... ) {
    1212        (global){};
    1313        check = 0;
  • tests/concurrency/readyQ/barrier_sleeper.cfa

    r8f448e0 r5e0b6657  
    1717// Processors and thread are removed in an interleaved fashion for a weirder case.
    1818
    19 #include <concurrency/barrier.hfa>
     19#include <barrier.hfa>
    2020#include <fstream.hfa>
    2121#include <time.hfa>
  • tests/concurrency/signal/block.cfa

    r8f448e0 r5e0b6657  
    8080        [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = active_thread();
    8181
    82         if( !is_empty( cond ) ) {
     82        if( ! empty( cond ) ) {
    8383
    8484                thread$ * next = ( thread$ * ) front( cond );
  • tests/concurrency/waituntil/futures.cfa

    r8f448e0 r5e0b6657  
    1 #include <select.hfa>
     1#include <fstream.hfa>
    22#include <future.hfa>
    33#include <thread.hfa>
     
    55future(int) A, B, C;
    66
    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);
     7thread Server {};
     8void main( Server & ) {
     9        B( 3 ); // fulfil( B, 3 );
     10        A( 2 );
     11        C( 4 );
    2212}
    2313
    2414int 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";
    6155}
  • tests/io/comp_basic.cfa

    r8f448e0 r5e0b6657  
    1616
    1717
    18 #include <concurrency/barrier.hfa>
     18#include <barrier.hfa>
    1919#include <fstream.hfa>
    2020#include <iofwd.hfa>
  • tests/io/comp_fair.cfa

    r8f448e0 r5e0b6657  
    1616
    1717
    18 #include <concurrency/barrier.hfa>
     18#include <barrier.hfa>
    1919#include <fstream.hfa>
    2020#include <iofwd.hfa>
Note: See TracChangeset for help on using the changeset viewer.