Esempio n. 1
0
__inline void ttas_spinlock_lock(volatile bool* lock)
{
    uint16_t test_counter = 0;
    while (true)
    {
        if (*lock == 0)
        {
            test_counter = 0;
            if (_InterlockedCompareExchange8((volatile char*)lock, 1, 0) == 0)
            {
                //MemoryBarrier();
                return;
            }
        }
        else
        {
            if ((test_counter & 0xFFFF) == 0xFFFF)
            {
#if FDP_POWER_SAVE == 1
                Sleep(10);
#endif
            }
            else
            {
                test_counter++;
            }
        }
    }
}
Esempio n. 2
0
	/* _Atomic_compare_exchange_weak_1, _Atomic_compare_exchange_strong_1 */
static int _Compare_exchange_seq_cst_1(volatile _Uint1_t *_Tgt,
	_Uint1_t *_Exp, _Uint1_t _Value)
	{	/* compare and exchange values atomically with
			sequentially consistent memory order */
	_Uint1_t res;
	_Uint1_t prev = _InterlockedCompareExchange8((volatile char *)_Tgt,
		_Value, *_Exp);
	if (prev == *_Exp)
		res = 1;
	else
		{	/* copy old value */
		res = 0;
		*_Exp = prev;
		}

	return (res);
	}
Esempio n. 3
0
char test_InterlockedCompareExchange8(char volatile *Destination, char Exchange, char Comperand) {
  return _InterlockedCompareExchange8(Destination, Exchange, Comperand);
}