Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming.threads > #2069
| From | aminer <aminer@toto.net> |
|---|---|
| Newsgroups | comp.programming.threads, comp.programming |
| Subject | About my RWLockX 2.11 algorithm |
| Date | 2014-01-28 15:40 -0800 |
| Organization | albasani.net |
| Message-ID | <lc94j6$r59$1@news.albasani.net> (permalink) |
Cross-posted to 2 groups.
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.
Back to comp.programming.threads | Previous | Next | Find similar | Unroll thread
About my RWLockX 2.11 algorithm aminer <aminer@toto.net> - 2014-01-28 15:40 -0800
csiph-web