• Pavan Balaji's avatar
    Initial version of the intelligent thread yielding. · b39314a5
    Pavan Balaji authored
    Instead of a simple thread yield, this patch adds some additional
    information to the yield about how many threads are waiting for it.
    When a thread tries to acquire a lock, they increment a counter.  When
    a thread needs to yield, it can check this counter to see how many
    threads are waiting to get the lock.  If there are no threads waiting,
    the yield can be skipped.
    This patch contains various changes to make that happen:
    1. We modify the mutex object to maintain additional information on
    the number of queued threads.
    2. We improve the yield call to include the unlock and lock as well,
    since it needs to decide whether to do the unlock/lock based on how
    many other threads are queued up.
    Signed-off-by: default avatarHalim Amer <aamer@anl.gov>