Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #4169 > unrolled thread
| Started by | aminer <aminer@toto.net> |
|---|---|
| First post | 2014-03-23 14:54 -0700 |
| Last post | 2014-03-23 14:54 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.programming
Scalable RWLock 3.06 aminer <aminer@toto.net> - 2014-03-23 14:54 -0700
| From | aminer <aminer@toto.net> |
|---|---|
| Date | 2014-03-23 14:54 -0700 |
| Subject | Scalable 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.
Back to top | Article view | comp.programming
csiph-web