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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
From aminer <aminer@toto.net>
Newsgroups comp.programming.threads, comp.programming
Subject Anderson array based Lock and MCS queue Lock
Date Wed, 02 Oct 2013 09:46:11 -0700
Organization albasani.net
Lines 58
Message-ID <l2hik5$3dv$1@news.albasani.net> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net dOUH+1LMFk9ihtldtUwZIgL6sOVQ/9Gp5QrqGa5z9l8SX4JCBY7Ms63vrmCfgX7t7MuV6+2xlVDhRiAc3M5dxg==
NNTP-Posting-Date Wed, 2 Oct 2013 16:45:57 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="ZMTTRiebcj3JAxL2mSJKYBJNm8AJ8FUnWna4ETHXOmv2iVU4KVSeq4TzYvuecTAfhsRRhmAayX51tP8eD/F2A7TA3v4vLRDxY7Qst+T/f1IS94VsOBdFVmvcVjpSwPXz"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
Cancel-Lock sha1:pUw3kgnRJcCaCj7PFGc5sx0pLTY=
Xref csiph.com comp.programming.threads:1767 comp.programming:3816

Cross-posted to 2 groups.

Show key headers only | 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