Ignore:
Timestamp:
Feb 25, 2020, 1:17:58 PM (22 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
930b504
Parents:
3d5701e (diff), a254fa56 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/park/force_preempt.cfa

    r3d5701e r7dc2e015  
    1616}
    1717
    18 thread Waiter;
    1918thread Waiter {};
    20 
    2119
    2220volatile int count = 0;
     
    2523        // Get a unique id
    2624        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;
    2727
    2828        for(int i = 0; i < 5; i++) {
     29                assert(mask == 0xCAFEBABA);
     30
    2931                // Unpark this thread, don't force a yield
    30                 sout | id | "Calling unpark" | i;
    3132                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));
    3238
    3339                // Force a preemption before the call to park
     
    3642
    3743                // Park this thread,
    38                 sout | id | "Parking" | i;
     44                assert(mask == (id_hash ^ 0xCAFEBABA));
    3945                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);
    4151        }
    4252}
Note: See TracChangeset for help on using the changeset viewer.