Discussion:
Distributed Reader-Writer Mutex 1.0
(too old to reply)
aminer
2012-09-12 17:53:21 UTC
Permalink
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.
aminer
2012-09-13 17:34:55 UTC
Permalink
Hello,

Distributed Reader-Writer Mutex have been updated to version 1.02.

I have provided you now with two versions

In the first version i have not used GetCurrectProcessor() but i have used
GetCurrectThreadID() , and i have also provided you with a second
version that scales better, to be able to use the second version please use
the version2 in defines.inc, i have given you a test.pas example for
the first version and test1.pas for the second version, but don't forget to
use version2 inside defines.inc, to use the second version just uncomment
the version2 inside defines.inc and comment version1.

I have also done a cache line alignement in TOmniMREW, this has allowed
Drwlock to scale better.



You can download Distributed Reader-Writer Mutex version 1.02 from:

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



Thank you,
Amine Moulay Ramdane.
Post by aminer
Hello,
Distributed Reader-Writer Mutex 1.0
Distributed Reader-Writer Mutex, based on the Dmitry Vyukov
C++ Distributed Reader-Writer Mutex , I have included the following
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()
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
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);
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)
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
{$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
http://pages.videotron.com/aminer/
Thank you,
Amine Moulay Ramdane.
aminer
2012-09-13 19:46:45 UTC
Permalink
"aminer" <aminHello,

Here is some scalability numbers:

I have used TOmniMREW of the Omnithread library and used
only EnterReadLock() and ExitReadLock() with four threads on a
quad cores and TOmniMREW gave a negative scalability of -5.51x

And when i have used the second version of Distributed Reader-Writer Mutex
1.02 using only rlock() and runlock() , it gave me 3.94X scalability with
four threads on four cores. So now it's scaling.


And about the second version , don't forget to initialize the number that
you pass to rlock() and runlock() to 0 before
calling rlock() and runlock() .



Thank you,
Amine Moulay Ramdane.
Post by aminer
Hello,
Distributed Reader-Writer Mutex 1.0
Distributed Reader-Writer Mutex, based on the Dmitry Vyukov
C++ Distributed Reader-Writer Mutex , I have included the following
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()
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
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);
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)
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
{$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
http://pages.videotron.com/aminer/
Thank you,
Amine Moulay Ramdane.
August Karlstrom
2012-09-19 17:12:34 UTC
Permalink
On 2012-09-12 19:53, aminer wrote:
[...]
Post by aminer
The Object Pascal Distributed Reader-Writer Mutex 1.0
is based on the following C++ Distributed Reader-Writer Mutex
by Dmitry Vyukov
[...]

Your Pascal related post is off topic in this newsgroup. This is
comp.lang.oberon you know. Try one of the many Pascal newsgroups instead.

/August
Anonymous
2012-09-20 14:39:12 UTC
Permalink
I already outed the son of a bitch to his news host. He spams all of usenet
with his oral diarrhea. He is in my killfile now but I propose you all
complain to his email and news hosts as well. Get a copy of the raw post
including all headers and email the abuse contacts with the copy.
Post by August Karlstrom
[...]
Post by aminer
The Object Pascal Distributed Reader-Writer Mutex 1.0
is based on the following C++ Distributed Reader-Writer Mutex
by Dmitry Vyukov
[...]
Your Pascal related post is off topic in this newsgroup. This is
comp.lang.oberon you know. Try one of the many Pascal newsgroups instead.
/August
Loading...