Ignore:
File:
1 edited

Legend:

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

    ra254fa56 rb0c7419  
    1616}
    1717
     18thread Waiter;
    1819thread Waiter {};
     20
    1921
    2022volatile int count = 0;
     
    2325        // Get a unique id
    2426        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 
    3129                // Unpark this thread, don't force a yield
     30                sout | id | "Calling unpark" | i;
    3231                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));
    3832
    3933                // Force a preemption before the call to park
     
    4236
    4337                // Park this thread,
    44                 assert(mask == (id_hash ^ 0xCAFEBABA));
     38                sout | id | "Parking" | i;
    4539                park();
    46                 assert(mask == (id_hash ^ 0xCAFEBABA));
    47 
    48                 // Reset the hash and recheck it
    49                 mask ^= id_hash;
    50                 assert(mask == 0xCAFEBABA);
     40                sout | id | "Unparked" | i;
    5141        }
    5242}
Note: See TracChangeset for help on using the changeset viewer.