Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!easy.in-chemnitz.de!news2.arglkargh.de!news.albasani.net!.POSTED!not-for-mail From: aminer Newsgroups: comp.programming.threads,comp.programming Subject: Re: Anderson array based Lock and MCS queue Lock Date: Wed, 02 Oct 2013 11:08:27 -0700 Organization: albasani.net Lines: 88 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net wG27+Z8axLb4oDLAddMJf/EnOKZaNoMpCHcoEcSrV/BN6RosUNKjDhZIdpHm6bnGt088aeSZ+24lFAQRYQSrgw== NNTP-Posting-Date: Wed, 2 Oct 2013 18:07:56 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="LJ2ogo2Wm7Lv187ubKtI6LnKt+J4fnzYB25PCZZfuj/Q9lh0ZVx8Ru8ZJGDe57h7pQu2czIIGWB0yY/sdgCH3D+dSwYnIa8ykqEeb0z++vdMuLDEBrRXy1C98eBR9w/T"; 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 In-Reply-To: Cancel-Lock: sha1:A5xR7XK04ZdX8oPmJS0/yj4zcFs= Xref: csiph.com comp.programming.threads:1768 comp.programming:3817 I wrote: "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" If you have noticed if there context switches the thread that must enter the Lock must wait longer and it must wait the other thread on the same core to have a cache miss, so this will be slow and this is not good, so this is why the Anderson array based Lock is not scalable , and i have done some benchmarks on the Anderson array based Lock and it's doesn't scale when there is more threads than the number of cores, this problem doesn't happen with my scalable distributed Lock. Thank you, Amine Moulay Ramdane. On 10/2/2013 9:46 AM, aminer wrote: > > 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.