<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Scalable Distributed Fair Lock 1.03 in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Scalable-Distributed-Fair-Lock-1-03/m-p/966007#M5414</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Hello,&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Scalable Distributed Fair Lock 1.03&lt;/STRONG&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;IMG src="http://pages.videotron.com/aminer/avatar.gif" /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;STRONG&gt;Authors:&lt;/STRONG&gt;&lt;STRONG&gt; Amine Moulay Ramdane.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt; Click here to download the zip file:&lt;/STRONG&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;STRONG&gt;&lt;A href="http://pages.videotron.com/aminer/zip/DFLOCK.zip"&gt;Zip&lt;/A&gt; (for FreePascal and Lazarus and Delphi 7 to 2007)&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;/STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;Description:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;A scalable distributed&amp;nbsp;Lock, it is as fast as the Windows critical section and it is FIFO fair when there is contention , so i think it avoids starvation and it reduces the cache-coherence traffic. My Scalable and distributed Lock uses now a Ticket mechanism , so&amp;nbsp;it's FIFO fair when there is contention, but my Scalable distributed Lock is more efficient than the Ticket Spinlock cause it's distributed and hence the threads spins locally on&amp;nbsp;variables on the local caches on the same core, so it minimizes efficiently&amp;nbsp;the cache-cohence traffic, so my scalable distributed Lock is more efficient than the Ticket Spinlock.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I have not used a Waitfree queue to implement my Scalable Distributed Lock, &amp;nbsp;but you can use a Waitfree queue so &lt;/STRONG&gt;&lt;STRONG&gt;that my Scalable Distributed Lock will be more efficient.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you want to add a backoff mechanism to the Ticket Lock , since the locked region can have a variable length, so it's not &amp;nbsp;easy to come with a backoff mechanism that minimizes&amp;nbsp;efficientlythe cache-coherence traffic, that's the same for a Spinlock with an exponential backoff , so how can we do it&amp;nbsp; ? if you take a look at the source code of my scalable distributed fair lock you will notice that there is two places where i am using a Ticket mechanism , inside the LW_DFLOCK.pas and inside the FIFO queue inside the source code lockfree_mpmc.pas, but for the first Ticketmechanism that i am using inside LW_DFLOCK.pas we don't need a backoff to reduce the cache-coherence traffic, cause it is spinning locally on a variable inside the same core, but for the FIFO queue we need a backoff for its Ticket mechanism but this is not so difficult cause the locked region has a constant length, this is why i have added a backoff mechanism to the Ticket mechanism inside the push() method of lockfree_mpmc.pas, i have benchmarked it and it's giving a good performance, so this is why my scalable distributed fair lock is better than the Ticket spinlock and it's FIFO fair when there is contention, so it avoids also starvation. &lt;BR /&gt;&lt;BR /&gt;Note: You have to use a number of threads not greater than 1.5X times the number of cores so that the Ticket mechanism will be optimal. &lt;/P&gt;
&lt;P&gt;Click here to see the explanation of my scalable distributed Lock algorithm: &lt;A href="http://pages.videotron.com/aminer/DLOCK.html"&gt;Algorithm explanation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please take a look a the test.pas Object Pascal demo inside the zipfile, compile and run it...&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;Language&lt;/STRONG&gt;&lt;STRONG&gt;: FPC Pascal v2.2.0+ / Delphi 7+: &lt;/STRONG&gt;&lt;A href="http://www.freepascal.org/"&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;A href="http://www.freepascal.org/" target="_blank"&gt;http://www.freepascal.org/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;B&gt;Operating System&lt;/B&gt;&lt;/STRONG&gt;&lt;STRONG&gt;s: &lt;/STRONG&gt;&lt;STRONG&gt;Windows, Mac OSX , Linux , Unix... &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt; Required FPC switches: -O3 -Sd -dFPC -dFreePascal &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;-Sd for delphi mode....&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;{$DEFINE CPU32} and {$DEFINE Windows32} for 32 bit systems&lt;BR /&gt;&lt;BR /&gt;{$DEFINE CPU64} and {$DEFINE Windows64} for 64 bit systems&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Thank you,&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Amine Moulay Ramdane&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 26 Oct 2013 03:29:43 GMT</pubDate>
    <dc:creator>aminer10</dc:creator>
    <dc:date>2013-10-26T03:29:43Z</dc:date>
    <item>
      <title>Scalable Distributed Fair Lock 1.03</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Scalable-Distributed-Fair-Lock-1-03/m-p/966007#M5414</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hello,&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Scalable Distributed Fair Lock 1.03&lt;/STRONG&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;IMG src="http://pages.videotron.com/aminer/avatar.gif" /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;STRONG&gt;Authors:&lt;/STRONG&gt;&lt;STRONG&gt; Amine Moulay Ramdane.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt; Click here to download the zip file:&lt;/STRONG&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;STRONG&gt;&lt;A href="http://pages.videotron.com/aminer/zip/DFLOCK.zip"&gt;Zip&lt;/A&gt; (for FreePascal and Lazarus and Delphi 7 to 2007)&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;/STRONG&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;Description:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;A scalable distributed&amp;nbsp;Lock, it is as fast as the Windows critical section and it is FIFO fair when there is contention , so i think it avoids starvation and it reduces the cache-coherence traffic. My Scalable and distributed Lock uses now a Ticket mechanism , so&amp;nbsp;it's FIFO fair when there is contention, but my Scalable distributed Lock is more efficient than the Ticket Spinlock cause it's distributed and hence the threads spins locally on&amp;nbsp;variables on the local caches on the same core, so it minimizes efficiently&amp;nbsp;the cache-cohence traffic, so my scalable distributed Lock is more efficient than the Ticket Spinlock.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I have not used a Waitfree queue to implement my Scalable Distributed Lock, &amp;nbsp;but you can use a Waitfree queue so &lt;/STRONG&gt;&lt;STRONG&gt;that my Scalable Distributed Lock will be more efficient.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you want to add a backoff mechanism to the Ticket Lock , since the locked region can have a variable length, so it's not &amp;nbsp;easy to come with a backoff mechanism that minimizes&amp;nbsp;efficientlythe cache-coherence traffic, that's the same for a Spinlock with an exponential backoff , so how can we do it&amp;nbsp; ? if you take a look at the source code of my scalable distributed fair lock you will notice that there is two places where i am using a Ticket mechanism , inside the LW_DFLOCK.pas and inside the FIFO queue inside the source code lockfree_mpmc.pas, but for the first Ticketmechanism that i am using inside LW_DFLOCK.pas we don't need a backoff to reduce the cache-coherence traffic, cause it is spinning locally on a variable inside the same core, but for the FIFO queue we need a backoff for its Ticket mechanism but this is not so difficult cause the locked region has a constant length, this is why i have added a backoff mechanism to the Ticket mechanism inside the push() method of lockfree_mpmc.pas, i have benchmarked it and it's giving a good performance, so this is why my scalable distributed fair lock is better than the Ticket spinlock and it's FIFO fair when there is contention, so it avoids also starvation. &lt;BR /&gt;&lt;BR /&gt;Note: You have to use a number of threads not greater than 1.5X times the number of cores so that the Ticket mechanism will be optimal. &lt;/P&gt;
&lt;P&gt;Click here to see the explanation of my scalable distributed Lock algorithm: &lt;A href="http://pages.videotron.com/aminer/DLOCK.html"&gt;Algorithm explanation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please take a look a the test.pas Object Pascal demo inside the zipfile, compile and run it...&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;Language&lt;/STRONG&gt;&lt;STRONG&gt;: FPC Pascal v2.2.0+ / Delphi 7+: &lt;/STRONG&gt;&lt;A href="http://www.freepascal.org/"&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;A href="http://www.freepascal.org/" target="_blank"&gt;http://www.freepascal.org/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;B&gt;Operating System&lt;/B&gt;&lt;/STRONG&gt;&lt;STRONG&gt;s: &lt;/STRONG&gt;&lt;STRONG&gt;Windows, Mac OSX , Linux , Unix... &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt; Required FPC switches: -O3 -Sd -dFPC -dFreePascal &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;-Sd for delphi mode....&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;{$DEFINE CPU32} and {$DEFINE Windows32} for 32 bit systems&lt;BR /&gt;&lt;BR /&gt;{$DEFINE CPU64} and {$DEFINE Windows64} for 64 bit systems&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Thank you,&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Amine Moulay Ramdane&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2013 03:29:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Scalable-Distributed-Fair-Lock-1-03/m-p/966007#M5414</guid>
      <dc:creator>aminer10</dc:creator>
      <dc:date>2013-10-26T03:29:43Z</dc:date>
    </item>
  </channel>
</rss>

