Changes in src/tests/sched-int-barge.c [4cedd9f:83a071f9]
- File:
-
- 1 edited
-
src/tests/sched-int-barge.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/sched-int-barge.c
r4cedd9f r83a071f9 1 //----------------------------------------------------------------------------------------2 //----------------------------------------------------------------------------------------3 //4 // DEPRECATED TEST5 //6 //----------------------------------------------------------------------------------------7 //----------------------------------------------------------------------------------------8 9 1 #include <fstream> 10 2 #include <kernel> … … 13 5 #include <thread> 14 6 15 static const unsigned long N = 50_000ul;16 17 #ifndef PREEMPTION_RATE18 #define PREEMPTION_RATE 10_000ul19 #endif20 21 unsigned int default_preemption() {22 return 0;23 }24 7 enum state_t { WAIT, SIGNAL, BARGE }; 25 8 … … 27 10 28 11 monitor global_data_t { 29 volatilebool done;12 bool done; 30 13 int counter; 31 14 state_t state; … … 64 47 65 48 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); 69 52 70 if(c.do_wait1 == c.do_wait2) sout | "Same" | endl;53 // if(c.do_wait1 == c.do_wait2) sout | "Same" | endl; 71 54 } 72 55 73 56 if( action == c.do_wait1 || action == c.do_wait2 ) { 74 57 c.state = WAIT; 75 wait( cond );58 wait( &cond ); 76 59 77 60 if(c.state != SIGNAL) { … … 83 66 c.state = SIGNAL; 84 67 85 signal( cond );86 signal( cond );68 signal( &cond ); 69 signal( &cond ); 87 70 } 88 71 else { … … 90 73 } 91 74 92 if( c.counter >= N) c.done = true;75 if( c.counter >= 100_000 ) c.done = true; 93 76 return !c.done; 94 77 } … … 106 89 } 107 90 108 static thread_desc * volatile the_threads;109 110 91 int main(int argc, char* argv[]) { 111 92 rand48seed(0); … … 113 94 { 114 95 Threads t[17]; 115 the_threads = (thread_desc*)t;116 96 } 117 97 }
Note:
See TracChangeset
for help on using the changeset viewer.