Changeset 28e58fd for src/tests/sched-int-barge.c
- Timestamp:
- Aug 25, 2017, 10:38:34 AM (8 years ago)
- 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:
- 800d275
- Parents:
- af08051 (diff), 3eab308c (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/sched-int-barge.c
raf08051 r28e58fd 28 28 }; 29 29 30 void ?{} ( global_data_t *this ) {31 this ->done = false;32 this ->counter = 0;33 this ->state = BARGE;30 void ?{} ( global_data_t & this ) { 31 this.done = false; 32 this.counter = 0; 33 this.state = BARGE; 34 34 35 this ->do_signal = 6;36 this ->do_wait1 = 1;37 this ->do_wait2 = 3;35 this.do_signal = 6; 36 this.do_wait1 = 1; 37 this.do_wait2 = 3; 38 38 } 39 39 40 void ^?{} ( global_data_t *this ) {}40 void ^?{} ( global_data_t & this ) {} 41 41 42 42 global_t globalA; … … 48 48 thread Threads {}; 49 49 50 bool logicC( global_t * mutex a, global_t * mutex b, global_data_t *mutex c ) {51 c ->counter++;50 bool logicC( global_t & mutex a, global_t & mutex b, global_data_t & mutex c ) { 51 c.counter++; 52 52 53 if( (c ->counter % 1000) == 0 ) sout | c->counter | endl;53 if( (c.counter % 1000) == 0 ) sout | c.counter | endl; 54 54 55 int action = c ->counter % 10;55 int action = c.counter % 10; 56 56 57 57 if( action == 0 ) { 58 c ->do_signal = max( ((unsigned)rand48()) % 10, 1);59 c ->do_wait1 = ((unsigned)rand48()) % (c->do_signal);60 c ->do_wait2 = ((unsigned)rand48()) % (c->do_signal);58 c.do_signal = max( ((unsigned)rand48()) % 10, 1); 59 c.do_wait1 = ((unsigned)rand48()) % (c.do_signal); 60 c.do_wait2 = ((unsigned)rand48()) % (c.do_signal); 61 61 62 if(c ->do_wait1 == c->do_wait2) sout | "Same" | endl;62 if(c.do_wait1 == c.do_wait2) sout | "Same" | endl; 63 63 } 64 64 65 if( action == c ->do_wait1 || action == c->do_wait2 ) {66 c ->state = WAIT;65 if( action == c.do_wait1 || action == c.do_wait2 ) { 66 c.state = WAIT; 67 67 wait( &cond ); 68 68 69 if(c ->state != SIGNAL) {70 sout | "ERROR Barging detected" | c ->counter | endl;69 if(c.state != SIGNAL) { 70 sout | "ERROR Barging detected" | c.counter | endl; 71 71 abort(); 72 72 } 73 73 } 74 else if( action == c ->do_signal ) {75 c ->state = SIGNAL;74 else if( action == c.do_signal ) { 75 c.state = SIGNAL; 76 76 77 77 signal( &cond ); … … 79 79 } 80 80 else { 81 c ->state = BARGE;81 c.state = BARGE; 82 82 } 83 83 84 if( c ->counter >= N ) c->done = true;85 return !c ->done;84 if( c.counter >= N ) c.done = true; 85 return !c.done; 86 86 } 87 87 88 bool logicB( global_t * mutex a, global_t *mutex b ) {89 return logicC(a, b, &globalC);88 bool logicB( global_t & mutex a, global_t & mutex b ) { 89 return logicC(a, b, globalC); 90 90 } 91 91 92 bool logicA( global_t *mutex a ) {93 return logicB(a, &globalB);92 bool logicA( global_t & mutex a ) { 93 return logicB(a, globalB); 94 94 } 95 95 96 void main( Threads *this ) {97 while( logicA( &globalA) ) { yield(); };96 void main( Threads & this ) { 97 while( logicA(globalA) ) { yield(); }; 98 98 } 99 99 … … 101 101 102 102 int main(int argc, char* argv[]) { 103 104 105 106 107 108 103 rand48seed(0); 104 processor p; 105 { 106 Threads t[17]; 107 the_threads = (thread_desc*)t; 108 } 109 109 }
Note:
See TracChangeset
for help on using the changeset viewer.