Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

About my RWLockX 2.11 algorithm

0 views
Skip to first unread message

aminer

unread,
Jan 28, 2014, 6:40:53 PM1/28/14
to
Hello,

I will explain my new RWLockX algorithm (a scalable RWLock)...

My previous algorithms were not starvation-free, so if you have
frequent writes the reader threads may starve for long time or starve
completly.


So i had to be smarter than that , so if you look at my
previous algorithm, read this:

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


Inside the TRWLOCK.RLock() method i had done this:


if (FCount3^.fcount3 = 0)
then break
else
begin
LockedExchangeAdd(FCount1^[myid].fcount1,-1);
end;


So if the readers loop back so the algorithm will not
be starvation-free and if there is more writes the reader
threads may starve for a long time or starve completly.

So i had to change my previous algorithms and avoid completly the
looping back so that to avoid starvation.

And here is what i have done in my new RWLockX algorithm that
is starvation-free:

i have changed this part inside the TRWLOCK.RLock() method with this:


if (FCount3^.fcount3 = 0)
then break
else
begin
LockedExchangeAdd(nbr,1);
LockedExchangeAdd(FCount1^[myid].fcount1,-1);
event1.waitfor(INFINITE);
LockedExchangeAdd(FCount1^[myid].fcount1,1);;
LockedExchangeAdd(nbr,-1);
break;
end;


and in the write side inside the TRWLOCK.WLock() method
i have added this:

repeat;
event1.setevent;
event1.resetevent;
until nbr=0;

So that to avoid completly starvation and so that to avoid
a deadlock.

So my new scalable RWLockX algorithm supports now all the following
requirements:


1- It uses my SemaMonitor , hence it uses less CPU ressources.

2- It scales on multicores

3- It is starvation-free

4- it is portable.


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

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


Thank you,
Amine Moulay Ramdane.



0 new messages