Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #1767

Anderson array based Lock and MCS queue Lock

From aminer <aminer@toto.net>
Newsgroups comp.programming.threads, comp.programming
Subject Anderson array based Lock and MCS queue Lock
Date 2013-10-02 09:46 -0700
Organization albasani.net
Message-ID <l2hik5$3dv$1@news.albasani.net> (permalink)

Cross-posted to 2 groups.

Show all headers | View raw


Hello,

I have implemented an enhanced version of the Anderson array based Lock 
, and i have come to the conclusion that the Anderson array based Lock 
doesn't scale well, cause if there is more threads than the number of 
cores and there is context switches the thread that must enter the Lock 
can wait longer and this will not make the Anderson Lock scalable,
the same problem happens with the MCS queue Lock it doesn't scale well,
the Ticket Spinlock doens't scale either..


Here is my enhanced implementation of the Anderson array based Lock...

==============================================================================
procedure TALOCK.Enter;

var  count1,slot:long;

begin

repeat

count1:=LockedIncInt(count);

if count1<= FSize then break;

LockedDecInt(count);

sleep(0);

until false;

slot:=LockedIncInt(fcount2^.fcount2);
while Fcount1^[(slot-1) mod fsize].fcount1<>1
do sleep(0);

end;

//==============================================================================

procedure TALOCK.Leave;

begin
FCount1^[fcount3^.fcount3 mod fsize].FCount1 := 0;
inc(fcount3^.fcount3);
LockedDecInt(count);
FCount1^[fcount3^.fcount3  mod fsize].FCount1 := 1;

end;
end.

---



Thank you,
Amine Moulay Ramdane.

Back to comp.programming.threads | Previous | NextNext in thread | Find similar


Thread

Anderson array based Lock and MCS queue Lock aminer <aminer@toto.net> - 2013-10-02 09:46 -0700
  Re: Anderson array based Lock and MCS queue Lock aminer <aminer@toto.net> - 2013-10-02 11:08 -0700

csiph-web