Esempio n. 1
0
        public void Unlock()
        {
            var me = ThreadId.Get();

            Volatile.Write(ref _second[me], false);
            Volatile.Write(ref _first[me], false);
        }
        public void Lock()
        {
            var i = ThreadId.Get();
            var j = 1 - i;

            Volatile.Write(ref _flag[i], true);
            Thread.MemoryBarrier();
            _victim = i;

            while (Volatile.Read(ref _flag[j]) && _victim == i)
            {
            }
        }
Esempio n. 3
0
        public void Lock()
        {
            var me = ThreadId.Get();

            for (var i = 1; i < _count; i++)
            {
                Volatile.Write(ref _level[me], i);
                Volatile.Write(ref _victim[i], me);

                while (LevelCondition(me, i) && Volatile.Read(ref _victim[i]) == me)
                {
                    Wait(me);
                }
            }
        }
Esempio n. 4
0
        public void Lock()
        {
            var me = ThreadId.Get();

            Volatile.Write(ref _flag[me], true);

            var max = VolatileMax(_label);

            Volatile.Write(ref _label[me], max + 1);
            // _label[me] = _label.Max() + 1;

            while (Condition(me))
            {
                Wait(me);
            }
        }
Esempio n. 5
0
        public void Lock()
        {
            var me = ThreadId.Get();

            Volatile.Write(ref _first[me], true);

            while (!Volatile.Read(ref _second[me]) || OthersCondition(me))
            {
                if (_k != me)
                {
                    Volatile.Write(ref _second[me], false);
                    if (!Volatile.Read(ref _first[_k]))
                    {
                        _k = me;
                    }
                }
                else
                {
                    Volatile.Write(ref _second[me], true);
                }
                Wait(me);
            }
        }
 public void Unlock()
 {
     Volatile.Write(ref _flag[ThreadId.Get()], false);
 }
        public void Unlock()
        {
            var i = _firstThreadId == ThreadId.Get() ? 0 : 1;

            Volatile.Write(ref _flag[i], false);
        }
 public void SetFirstThreadId()
 {
     _firstThreadId = ThreadId.Get();
 }
Esempio n. 9
0
 public void Unlock()
 {
     Volatile.Write(ref _level[ThreadId.Get()], 0);
 }