- Timestamp:
- May 30, 2017, 7:49:45 AM (9 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:
- f3fc631f
- Parents:
- 8f61052c (diff), 4a368547 (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. - Location:
- src/tests
- Files:
-
- 2 edited
-
sched-int-block.c (modified) (4 diffs)
-
sched-int-disjoint.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/sched-int-block.c
r8f61052c r2ab67b9 10 10 11 11 monitor global_data_t { 12 state_t state;13 bool ran;12 thread_desc * last_thread; 13 thread_desc * last_signaller; 14 14 }; 15 15 16 16 void ?{} ( global_data_t * this ) { 17 this->state = BARGE; 17 this->last_thread = NULL; 18 this->last_signaller = NULL; 18 19 } 19 20 … … 28 29 //------------------------------------------------------------------------------ 29 30 void wait_op( global_data_t * mutex a, global_data_t * mutex b, unsigned i ) { 30 wait( &cond ); 31 a->ran = b->ran = true; 31 wait( &cond, (uintptr_t)this_thread() ); 32 32 33 33 yield( ((unsigned)rand48()) % 10 ); 34 34 35 if(a-> state != SIGNAL || b->state != SIGNAL) {36 sout | "ERROR Barging detected " | a->state | b->state| endl;35 if(a->last_thread != a->last_signaller || b->last_thread != b->last_signaller ) { 36 sout | "ERROR Barging detected, expected" | a->last_signaller | b->last_signaller | "got" | a->last_thread | b->last_thread | endl; 37 37 abort(); 38 38 } 39 39 40 a-> state = b->state = WAITED;40 a->last_thread = b->last_thread = this_thread(); 41 41 42 42 yield( ((unsigned)rand48()) % 10 ); … … 54 54 yield( ((unsigned)rand48()) % 10 ); 55 55 56 a->ran = b->ran = false; 57 a->state = b->state = SIGNAL; 56 a->last_thread = b->last_thread = a->last_signaller = b->last_signaller = this_thread(); 58 57 59 signal_block( &cond );58 if( !is_empty( &cond ) ) { 60 59 61 yield( ((unsigned)rand48()) % 10);60 thread_desc * next = front( &cond ); 62 61 63 assert(a->ran == b->ran); 64 if(a->ran) 65 { 66 if(a->state != WAITED || b->state != WAITED) { 67 sout | "ERROR Barging detected" | a->state | b->state | endl; 62 if( ! signal_block( &cond ) ) { 63 sout | "ERROR expected to be able to signal" | endl; 64 abort(); 65 } 66 67 yield( ((unsigned)rand48()) % 10 ); 68 69 if(a->last_thread != next || b->last_thread != next) { 70 sout | "ERROR Barging detected, expected" | next | "got" | a->last_thread | b->last_thread | endl; 68 71 abort(); 69 72 } … … 81 84 //------------------------------------------------------------------------------ 82 85 void barge_op( global_data_t * mutex a ) { 83 a-> state = BARGE;86 a->last_thread = this_thread(); 84 87 } 85 88 -
src/tests/sched-int-disjoint.c
r8f61052c r2ab67b9 78 78 signal( &cond, a, &data ); 79 79 80 int pauses = (unsigned)rand48() % 10; 81 for(int i = 0; i < pauses; i++) { 82 yield(); 83 } 80 yield( (unsigned)rand48() % 10 ); 84 81 85 82 //This is technically a mutual exclusion violation but the mutex monitor protects us
Note:
See TracChangeset
for help on using the changeset viewer.