Esempio n. 1
0
/**
 *  Acquisition of a ticket lock entails an increment, then a spin.  We use a
 *  counter to measure how long we spend spinning, in case that information
 *  is useful to adaptive STM mechanisms.
 */
inline int ticket_acquire(ticket_lock_t* lock)
{
    int ret = 0;
    uintptr_t my_ticket = faiptr(&lock->next_ticket);
    while (lock->now_serving != my_ticket)
        ret++;
    return ret;
}
Esempio n. 2
0
 /**
  *  On begin, we must get a timestamp.  For now, we use a global
  *  counter, which is a bottleneck but ensures uniqueness.
  */
 static void onBegin(TxThread* tx)
 {
     // acquire timestamp when transaction begins
     epochs[tx->id-1].val = faiptr(&fcm_timestamp.val);
     // could use (INT32_MAX & tick())
 }