Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.pascal.misc > #678
| From | aminer <aminer@toto.net> |
|---|---|
| Newsgroups | comp.lang.pascal.misc |
| Subject | Scalable RWLock 3.06 |
| Date | 2014-03-23 14:54 -0700 |
| Organization | albasani.net |
| Message-ID | <lgnalj$eis$3@news.albasani.net> (permalink) |
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.lang.pascal.misc | Previous | Next | Find similar
Scalable RWLock 3.06 aminer <aminer@toto.net> - 2014-03-23 14:54 -0700
csiph-web