Ignore:
File:
1 edited

Legend:

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

    r4cedd9f r83a071f9  
    1 //----------------------------------------------------------------------------------------
    2 //----------------------------------------------------------------------------------------
    3 //
    4 //              DEPRECATED TEST
    5 //
    6 //----------------------------------------------------------------------------------------
    7 //----------------------------------------------------------------------------------------
    8 
    91#include <fstream>
    102#include <kernel>
     
    135#include <thread>
    146
    15 static const unsigned long N = 50_000ul;
    16 
    17 #ifndef PREEMPTION_RATE
    18 #define PREEMPTION_RATE 10_000ul
    19 #endif
    20 
    21 unsigned int default_preemption() {
    22         return 0;
    23 }
    247enum state_t { WAIT, SIGNAL, BARGE };
    258
     
    2710
    2811monitor global_data_t {
    29         volatile bool done;
     12        bool done;
    3013        int counter;
    3114        state_t state;
     
    6447
    6548        if( action == 0 ) {
    66                 c.do_signal = max( rand48(10), 1);
    67                 c.do_wait1 = rand48(c.do_signal);
    68                 c.do_wait2 = rand48(c.do_signal);
     49                c.do_signal = max( ((unsigned)rand48()) % 10, 1);
     50                c.do_wait1 = ((unsigned)rand48()) % (c.do_signal);
     51                c.do_wait2 = ((unsigned)rand48()) % (c.do_signal);
    6952
    70                 if(c.do_wait1 == c.do_wait2) sout | "Same" | endl;
     53                // if(c.do_wait1 == c.do_wait2) sout | "Same" | endl;
    7154        }
    7255
    7356        if( action == c.do_wait1 || action == c.do_wait2 ) {
    7457                c.state = WAIT;
    75                 wait( cond );
     58                wait( &cond );
    7659
    7760                if(c.state != SIGNAL) {
     
    8366                c.state = SIGNAL;
    8467
    85                 signal( cond );
    86                 signal( cond );
     68                signal( &cond );
     69                signal( &cond );
    8770        }
    8871        else {
     
    9073        }
    9174
    92         if( c.counter >= N ) c.done = true;
     75        if( c.counter >= 100_000 ) c.done = true;
    9376        return !c.done;
    9477}
     
    10689}
    10790
    108 static thread_desc * volatile the_threads;
    109 
    11091int main(int argc, char* argv[]) {
    11192        rand48seed(0);
     
    11394        {
    11495                Threads t[17];
    115                 the_threads = (thread_desc*)t;
    11696        }
    11797}
Note: See TracChangeset for help on using the changeset viewer.