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


Groups > comp.programming.threads > #2124

Scalable RWLock 3.06

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 Scalable RWLock 3.06
Date Sun, 23 Mar 2014 14:54:23 -0700
Organization albasani.net
Lines 105
Message-ID <lgnakg$eis$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 u2s/jTWWgAJ77ksLtstNF4wOjMFaKiBLD3jr+2YKiXM01Swm5CHKW4ben+FhRy25dzh9k1Wh8RPLWdJF1/3kfMhokZucztbvxKK604gSpL/e0d8fMjJJZvmdq57OkeLS
NNTP-Posting-Date Sun, 23 Mar 2014 18:54:08 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="UvZd6sUUeqUwlfhD/sYe2YVgr/CfYbOEUiTGSCfjlZtHdNvSZoPc8EN/fTpbcyci9GDfOOj3Lq3WC6sijj3IcWNrPFLW8CCLxfxveuKTH879gU7rRMTOUYEepGHYxcBz"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (Windows NT 6.0; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
Cancel-Lock sha1:+t8MdAd7xHoPakZbNxxrxSodtY8=
Xref csiph.com comp.programming.threads:2124 comp.programming:4169

Cross-posted to 2 groups.

Show key headers only | View raw


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.



Back to comp.programming.threads | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web