Ignore:
Timestamp:
Feb 14, 2020, 3:28:17 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
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
Message:

Yield now uses force_yield instead of park/unpark.
Final ctxswitch of a thread now uses ad-hoc mechanism instead of park/unpark.

File:
1 edited

Legend:

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

    r50b8885 rb0c7419  
    2020
    2121
    22 void park_loop(Waiter & this, int id, bool force) {
     22volatile int count = 0;
     23
     24void main(Waiter & this) {
     25        // Get a unique id
     26        int id = __atomic_fetch_add(&count, 1, __ATOMIC_SEQ_CST);
    2327
    2428        for(int i = 0; i < 5; i++) {
    2529                // 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);
    2832
    2933                // Force a preemption before the call to park
     
    3236
    3337                // Park this thread,
    34                 sout | id | "Parking"  | (force ? "(Force)" : "(No Force)") | i;
     38                sout | id | "Parking" | i;
    3539                park();
    36                 sout | id | "Unparked" | (force ? "(Force)" : "(No Force)") | i;
     40                sout | id | "Unparked" | i;
    3741        }
    38 }
    39 
    40 volatile int count = 0;
    41 
    42 void main(Waiter & this) {
    43         // Get a unique id
    44         int id = __atomic_fetch_add(&count, 1, __ATOMIC_SEQ_CST);
    45 
    46         // First without forcing yield
    47         park_loop( this, id, false );
    48 
    49         // First with forcing yield
    50         park_loop( this, id, true  );
    5142}
    5243
Note: See TracChangeset for help on using the changeset viewer.