Changeset a254fa56


Ignore:
Timestamp:
Feb 25, 2020, 12:16:41 PM (20 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
7dc2e015, c886f4b
Parents:
dd9e1ca
Message:

Modified force_preempt to be deterministic

Location:
tests/concurrent/park
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/park/.expect/force_preempt.txt

    rdd9e1ca ra254fa56  
    1 0 Calling unpark 0
    2 1 Calling unpark 0
    3 2 Calling unpark 0
    4 3 Calling unpark 0
    5 4 Calling unpark 0
    6 0 Parking 0
    7 0 Unparked 0
    8 0 Calling unpark 1
    9 1 Parking 0
    10 1 Unparked 0
    11 1 Calling unpark 1
    12 2 Parking 0
    13 2 Unparked 0
    14 2 Calling unpark 1
    15 3 Parking 0
    16 3 Unparked 0
    17 3 Calling unpark 1
    18 4 Parking 0
    19 4 Unparked 0
    20 4 Calling unpark 1
    21 0 Parking 1
    22 0 Unparked 1
    23 0 Calling unpark 2
    24 1 Parking 1
    25 1 Unparked 1
    26 1 Calling unpark 2
    27 2 Parking 1
    28 2 Unparked 1
    29 2 Calling unpark 2
    30 3 Parking 1
    31 3 Unparked 1
    32 3 Calling unpark 2
    33 4 Parking 1
    34 4 Unparked 1
    35 4 Calling unpark 2
    36 0 Parking 2
    37 0 Unparked 2
    38 0 Calling unpark 3
    39 1 Parking 2
    40 1 Unparked 2
    41 1 Calling unpark 3
    42 2 Parking 2
    43 2 Unparked 2
    44 2 Calling unpark 3
    45 3 Parking 2
    46 3 Unparked 2
    47 3 Calling unpark 3
    48 4 Parking 2
    49 4 Unparked 2
    50 4 Calling unpark 3
    51 0 Parking 3
    52 0 Unparked 3
    53 0 Calling unpark 4
    54 1 Parking 3
    55 1 Unparked 3
    56 1 Calling unpark 4
    57 2 Parking 3
    58 2 Unparked 3
    59 2 Calling unpark 4
    60 3 Parking 3
    61 3 Unparked 3
    62 3 Calling unpark 4
    63 4 Parking 3
    64 4 Unparked 3
    65 4 Calling unpark 4
    66 0 Parking 4
    67 0 Unparked 4
    68 1 Parking 4
    69 1 Unparked 4
    70 2 Parking 4
    71 2 Unparked 4
    72 3 Parking 4
    73 3 Unparked 4
    74 4 Parking 4
    75 4 Unparked 4
  • tests/concurrent/park/force_preempt.cfa

    rdd9e1ca ra254fa56  
    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.