Hello all,
I have to be smart more than that, so be smart with me...
In my previous post i have told you that i have to upgrade my
SemaCondvar and SemaMonitor objects, but i have thought more
and i think i have to not upgrade it, the solution is that i
have to delete the following code inside my TRWLOCK.RLock() method:
if (FCount3^.fcount3 = 0)
then break
else
begin
LockedExchangeAdd(FCount1^[myid].fcount1,-1);
end;
look here at my LW_RWLOCK algorithm:
http://pages.videotron.com/aminer/rwlock1.htmlBut that's not all and that's not enough, i have to avoid the enhancement of my previous post so that my scalable RWLock algorithm will not favor more the reader side , cause if it favor more the reader side the write side can starve for a long time and this is bad , so i have thought more and i think i have found a solution for that , if you look at the interface of my SemaCondvar and SemaMonitor objects look here:
http://pages.videotron.com/aminer/I have implemented a method called "function WaitersBlocked:integer"
this WaitersBlocked() method will return how many waiters are blocked and this is enough to implement a much clever algorithm that do not
favor more the reader side, so i have to use my SemaMonitor on
both the reader side and the writer side of my scalable RWLock and on the reader side i have have also to look at how much Waiters there is Waiters Blocked on both the reader side and writer side by calling on
both the reader and the write side, if there is no writers threads on the writer side i will call the SignalAll() method of my SemaMonitor to wake up all the waiters on the reader side, but if the there is more than 1 waiter threads on the writer side i will signal only one thread of the waiters on the reader side, so that i give a chance to the other writer threads to run, and by using this new algorithm the writers side will not starve for a long time, and my new scalable RWLock algorithm will support all the following requirements:
1- it will use my new SemaMonitor on both the reader and writer side
so it will use less CPU ressources.
2- It will scale on multicores
3- It will be FIFO fair on both the reader and the writer side
so it will be starvation free.
So i will upgrade soon my scalable RWLock to support all those requirements.
Thank you,
Amine Moulay Ramdane.