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


Groups > comp.programming > #4169 > unrolled thread

Scalable RWLock 3.06

Started byaminer <aminer@toto.net>
First post2014-03-23 14:54 -0700
Last post2014-03-23 14:54 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.programming


Contents

  Scalable RWLock 3.06 aminer <aminer@toto.net> - 2014-03-23 14:54 -0700

#4169 — Scalable RWLock 3.06

Fromaminer <aminer@toto.net>
Date2014-03-23 14:54 -0700
SubjectScalable RWLock 3.06
Message-ID<lgnakg$eis$1@news.albasani.net>
Hello,

I have updated my scalable RWLock to 3.06, in this new
version i have optimized more scalable RWLockX and scalable LW_RWLockX..


Here is what have changed...


Before, the RWLock() method looked like this:


===
procedure TRWLOCK.WLock;

var i:integer;

begin

lock.wait;

event1.resetEvent;
event2.resetEvent;

FCount3^.fcount3:=1;

repeat;
   event2.setEvent;
   asm pause end;
   event2.resetEvent;
until nbr^.nbr=0;

for i:=0 to GetSystemThreadCount-1 do
  begin
    while (FCount1^[i].fcount1<>0)
     do
      begin
       //if mysleep=0 then sleep(0);
       //else sleep(1);
      end;
  end;

end;

===


To optimize it more you have to write it like this:

==

procedure TRWLOCK.WLock;

var i:integer;

begin

lock.wait;

repeat;
   event2.setEvent;
   asm pause end;
   event2.resetEvent;
until nbr^.nbr=0;

event1.resetEvent;
//event2.resetEvent;

FCount3^.fcount3:=1;



for i:=0 to GetSystemThreadCount-1 do
  begin
    while (FCount1^[i].fcount1<>0)
     do
      begin
       //if mysleep=0 then sleep(0);
       //else sleep(1);
      end;
  end;

end;

===


Since the repeat-until block is now located before FCount3^.fcount3:=1;
so this will give better parallelism to RWLockX and LW_RWLockX.


You can download all the variants of my scalable RWLock version 3.06 from:


http://pages.videotron.com/aminer/



Thank you,
Amine Moulay Ramdane.



[toc] | [standalone]


Back to top | Article view | comp.programming


csiph-web