Changeset e1e8408 for src/tests


Ignore:
Timestamp:
Oct 31, 2017, 11:17:46 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
0dc954b, 4cedd9f
Parents:
5434d04
Message:

Updated concurrency tests with bounded rand48

Location:
src/tests
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/tests/sched-ext-barge.c

    r5434d04 re1e8408  
    4242void main( barger_t & this ) {
    4343        yield();
    44         while( barge( global ) ) { yield(((unsigned)rand48()) % 10); }
     44        while( barge( global ) ) { yield( rand48(10) ); }
    4545}
    4646
    4747bool do_call( global_t & mutex this ) {
    48         yield(((unsigned)rand48()) % 10);
     48        yield(rand48(10));
    4949        if( this.state != WAITFOR && !this.done && this.started ) {
    5050                serr | "Barging before caller detected" | endl;
     
    5757thread caller_t {};
    5858void main( caller_t & this ) {
    59         while( do_call(global) ) { yield(((unsigned)rand48()) % 10); }
     59        while( do_call(global) ) { yield(rand48(10)); }
    6060}
    6161
     
    6363        this.started = true;
    6464        for( int i = 0; i < N; i++) {
    65                 yield(((unsigned)rand48()) % 10);
     65                yield(rand48(10));
    6666                this.state = WAITFOR;
    6767                waitfor(do_call, this) {
  • src/tests/sched-ext-dtor.c

    r5434d04 re1e8408  
    4545
    4646void main( dummy_t & this ) {
    47         yield(((unsigned)rand48()) % 10);
     47        yield(rand48(10));
    4848        set_state( this, MAIN );
    4949        waitfor( ^?{}, this ) {
     
    5858        for( int i = 0; i < N; i++ ){
    5959                dummy_t dummy[4];
    60                 yield( ((unsigned)rand48()) % 100 );
     60                yield( rand48(100) );
    6161        }
    6262        sout | "Stopping" | endl;
  • src/tests/sched-ext-recurse.c

    r5434d04 re1e8408  
    1515static const unsigned long N = 5_000ul;
    1616
    17 static inline void rand_yield() { yield(((unsigned)rand48()) % 10); }
     17static inline void rand_yield() { yield(rand48(10)); }
    1818
    1919enum state_t { FIRST, SECOND, THIRD, LAST, STOP };
     
    2323        for (i = 0; i < 4; i++)
    2424        {
    25                 int j = ((unsigned)rand48()) % 4;
     25                int j = rand48(4);
    2626                enum state_t t = array[j];
    2727                array[j] = array[i];
  • src/tests/sched-ext-when.c

    r5434d04 re1e8408  
    1515static const unsigned long N = 4_998ul;
    1616
    17 static inline void rand_yield() { yield(((unsigned)rand48()) % 10); }
     17static inline void rand_yield() { yield(rand48(10)); }
    1818
    1919monitor global_t {
  • src/tests/sched-ext.c

    r5434d04 re1e8408  
    2626volatile bool done;
    2727
    28 unsigned rand10() {
    29         return (unsigned)rand48() % 10;
    30 }
    31 
    3228//----------------------------------------------------------------------------------------------------
    3329// Acceptor
     
    3632void do_wait( global_t * mutex a ) {
    3733        sout | "Waiting to accept" | endl;
    38         yield( rand10() );
     34        yield( rand48(10) );
    3935
    4036        sout | "Accepting" | endl;
  • src/tests/sched-int-barge.c

    r5434d04 re1e8408  
    6464
    6565        if( action == 0 ) {
    66                 c.do_signal = max( ((unsigned)rand48()) % 10, 1);
    67                 c.do_wait1 = ((unsigned)rand48()) % (c.do_signal);
    68                 c.do_wait2 = ((unsigned)rand48()) % (c.do_signal);
     66                c.do_signal = max( rand48(10), 1);
     67                c.do_wait1 = rand48(c.do_signal);
     68                c.do_wait2 = rand48(c.do_signal);
    6969
    7070                if(c.do_wait1 == c.do_wait2) sout | "Same" | endl;
  • src/tests/sched-int-block.c

    r5434d04 re1e8408  
    4949        wait( &cond, (uintptr_t)this_thread );
    5050
    51         yield( ((unsigned)rand48()) % 10 );
     51        yield( rand48(10) );
    5252
    5353        if(a.last_thread != a.last_signaller || b.last_thread != b.last_signaller ) {
     
    5858        a.last_thread = b.last_thread = this_thread;
    5959
    60         yield( ((unsigned)rand48()) % 10 );
     60        yield( rand48(10) );
    6161}
    6262
     
    7070//------------------------------------------------------------------------------
    7171void signal_op( global_data_t & mutex a, global_data_t & mutex b ) {
    72         yield( ((unsigned)rand48()) % 10 );
     72        yield( rand48(10) );
    7373
    7474        [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread;
     
    8383                }
    8484
    85                 yield( ((unsigned)rand48()) % 10 );
     85                yield( rand48(10) );
    8686
    8787                if(a.last_thread != next || b.last_thread != next) {
  • src/tests/sched-int-disjoint.c

    r5434d04 re1e8408  
    8888        signal( &cond, a, data );
    8989
    90         yield( (unsigned)rand48() % 10 );
     90        yield( rand48(10) );
    9191
    9292        //This is technically a mutual exclusion violation but the mutex monitor protects us
  • src/tests/sched-int-wait.c

    r5434d04 re1e8408  
    6262
    6363        while( waiter_left != 0 ) {
    64                 unsigned action = (unsigned)rand48() % 4;
     64                unsigned action = rand48(4);
    6565                switch( action ) {
    6666                        case 0:
Note: See TracChangeset for help on using the changeset viewer.