Changeset 58fe85a for tests/concurrent/park/force_preempt.cfa
- Timestamp:
- Jan 7, 2021, 3:27:00 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2b4daf2, 64aeca0
- Parents:
- 3c64c668 (diff), eef8dfb (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
-
tests/concurrent/park/force_preempt.cfa (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/park/force_preempt.cfa
r3c64c668 r58fe85a 16 16 } 17 17 18 thread Waiter;19 18 thread Waiter {}; 20 21 19 22 20 volatile int count = 0; … … 25 23 // Get a unique id 26 24 int id = __atomic_fetch_add(&count, 1, __ATOMIC_SEQ_CST); 25 int id_hash = id | (id << 8) | (id << 16) | (id << 24); 26 int mask = 0xCAFEBABA; 27 27 28 28 for(int i = 0; i < 5; i++) { 29 assert(mask == 0xCAFEBABA); 30 29 31 // Unpark this thread, don't force a yield 30 sout | id | "Calling unpark" | i; 31 unpark(this); 32 unpark( this ); 33 assert(mask == 0xCAFEBABA); 34 35 // Hash the mask to make sure no one else messes with them 36 mask ^= id_hash; 37 assert(mask == (id_hash ^ 0xCAFEBABA)); 32 38 33 39 // Force a preemption before the call to park … … 36 42 37 43 // Park this thread, 38 sout | id | "Parking" | i;44 assert(mask == (id_hash ^ 0xCAFEBABA)); 39 45 park(); 40 sout | id | "Unparked" | i; 46 assert(mask == (id_hash ^ 0xCAFEBABA)); 47 48 // Reset the hash and recheck it 49 mask ^= id_hash; 50 assert(mask == 0xCAFEBABA); 41 51 } 42 52 } … … 47 57 Waiter waiters[5]; 48 58 } 59 printf( "done\n" ); // non-empty .expect file 49 60 }
Note:
See TracChangeset
for help on using the changeset viewer.