Changeset b0c7419 for tests/concurrent/park/force_preempt.cfa
- Timestamp:
- Feb 14, 2020, 3:28:17 PM (3 years ago)
- Branches:
- arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8c50aed
- Parents:
- 50b8885
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/park/force_preempt.cfa
r50b8885 rb0c7419 20 20 21 21 22 void park_loop(Waiter & this, int id, bool force) { 22 volatile int count = 0; 23 24 void main(Waiter & this) { 25 // Get a unique id 26 int id = __atomic_fetch_add(&count, 1, __ATOMIC_SEQ_CST); 23 27 24 28 for(int i = 0; i < 5; i++) { 25 29 // Unpark this thread, don't force a yield 26 sout | id | "Calling unpark" | (force ? "(Force)" : "(No Force)") |i;27 unpark(this , force);30 sout | id | "Calling unpark" | i; 31 unpark(this); 28 32 29 33 // Force a preemption before the call to park … … 32 36 33 37 // Park this thread, 34 sout | id | "Parking" | (force ? "(Force)" : "(No Force)")| i;38 sout | id | "Parking" | i; 35 39 park(); 36 sout | id | "Unparked" | (force ? "(Force)" : "(No Force)") |i;40 sout | id | "Unparked" | i; 37 41 } 38 }39 40 volatile int count = 0;41 42 void main(Waiter & this) {43 // Get a unique id44 int id = __atomic_fetch_add(&count, 1, __ATOMIC_SEQ_CST);45 46 // First without forcing yield47 park_loop( this, id, false );48 49 // First with forcing yield50 park_loop( this, id, true );51 42 } 52 43
Note: See TracChangeset
for help on using the changeset viewer.