Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #1059 > unrolled thread

Distributed Reader-Writer Mutex 1.0

Started by"aminer" <aminer@videotron.ca>
First post2012-09-12 08:52 -0500
Last post2012-09-13 15:51 -0500
Articles 9 — 1 participant

Back to article view | Back to comp.programming.threads


Contents

  Distributed Reader-Writer Mutex 1.0 "aminer" <aminer@videotron.ca> - 2012-09-12 08:52 -0500
    Re: Distributed Reader-Writer Mutex 1.0 "aminer" <aminer@videotron.ca> - 2012-09-12 09:27 -0500
    Re: Distributed Reader-Writer Mutex 1.0 "aminer" <aminer@videotron.ca> - 2012-09-12 09:34 -0500
    Re: Distributed Reader-Writer Mutex 1.0 "aminer" <aminer@videotron.ca> - 2012-09-12 09:43 -0500
    Re: Distributed Reader-Writer Mutex 1.0 "aminer" <aminer@videotron.ca> - 2012-09-13 12:22 -0500
    Re: Distributed Reader-Writer Mutex 1.0 "aminer" <aminer@videotron.ca> - 2012-09-13 14:46 -0500
    Re: Distributed Reader-Writer Mutex 1.0 "aminer" <aminer@videotron.ca> - 2012-09-13 15:22 -0500
    Re: Distributed Reader-Writer Mutex 1.0 "aminer" <aminer@videotron.ca> - 2012-09-13 15:31 -0500
    Re: Distributed Reader-Writer Mutex 1.0 "aminer" <aminer@videotron.ca> - 2012-09-13 15:51 -0500

#1059 — Distributed Reader-Writer Mutex 1.0

From"aminer" <aminer@videotron.ca>
Date2012-09-12 08:52 -0500
SubjectDistributed Reader-Writer Mutex 1.0
Message-ID<k2q0ij$rrt$1@dont-email.me>
Hello,


Distributed Reader-Writer Mutex 1.0


Description:

Distributed Reader-Writer Mutex, ported by Amine Moulay Ramdane
from the Dmitry Vyukov C++ Distributed Reader-Writer Mutex to
 Object Pascal, 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
nowboth 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.


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.

[toc] | [next] | [standalone]


#1060

From"aminer" <aminer@videotron.ca>
Date2012-09-12 09:27 -0500
Message-ID<k2q2kj$977$2@dont-email.me>
In reply to#1059
Hello,

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



Thank you,
Amine Moulay Ramdane.



"aminer" <aminer@videotron.ca> wrote in message 
news:k2q0ij$rrt$1@dont-email.me...
> Hello,
>
>
> Distributed Reader-Writer Mutex 1.0
>
>
> Description:
>
> Distributed Reader-Writer Mutex, ported by Amine Moulay Ramdane
> from the Dmitry Vyukov C++ Distributed Reader-Writer Mutex to
> Object Pascal, 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
> nowboth 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.
>
>
> 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.
>
> 

[toc] | [prev] | [next] | [standalone]


#1061

From"aminer" <aminer@videotron.ca>
Date2012-09-12 09:34 -0500
Message-ID<k2q31u$bon$2@dont-email.me>
In reply to#1059
Hello,

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 can download Distributed Reader-Writer Mutex 1.0 from:

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


Thank you,
Amine Moulay Ramdane.


"aminer" <aminer@videotron.ca> wrote in message 
news:k2q0ij$rrt$1@dont-email.me...
> Hello,
>
>
> Distributed Reader-Writer Mutex 1.0
>
>
> Description:
>
> Distributed Reader-Writer Mutex, ported by Amine Moulay Ramdane
> from the Dmitry Vyukov C++ Distributed Reader-Writer Mutex to
> Object Pascal, 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
> nowboth 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.
>
>
> 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.
>
> 

[toc] | [prev] | [next] | [standalone]


#1062

From"aminer" <aminer@videotron.ca>
Date2012-09-12 09:43 -0500
Message-ID<k2q3im$f2k$2@dont-email.me>
In reply to#1059
Hello,

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


That's all.


Thank you,
Amine Moulay Ramdane






"aminer" <aminer@videotron.ca> wrote in message 
news:k2q0ij$rrt$1@dont-email.me...
> Hello,
>
>
> Distributed Reader-Writer Mutex 1.0
>
>
> Description:
>
> Distributed Reader-Writer Mutex, ported by Amine Moulay Ramdane
> from the Dmitry Vyukov C++ Distributed Reader-Writer Mutex to
> Object Pascal, 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
> nowboth 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.
>
>
> 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.
>
> 

[toc] | [prev] | [next] | [standalone]


#1066

From"aminer" <aminer@videotron.ca>
Date2012-09-13 12:22 -0500
Message-ID<k2t19b$atc$1@dont-email.me>
In reply to#1059
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.



Thank you,
Amine Moulay Ramdane.










"aminer" <aminer@videotron.ca> wrote in message 
news:k2q0ij$rrt$1@dont-email.me...
> Hello,
>
>
> Distributed Reader-Writer Mutex 1.0
>
>
> Description:
>
> Distributed Reader-Writer Mutex, ported by Amine Moulay Ramdane
> from the Dmitry Vyukov C++ Distributed Reader-Writer Mutex to
> Object Pascal, 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
> nowboth 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.
>
>
> 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.
>
> 

[toc] | [prev] | [next] | [standalone]


#1067

From"aminer" <aminer@videotron.ca>
Date2012-09-13 14:46 -0500
Message-ID<k2t9le$386$1@dont-email.me>
In reply to#1059
Hello,

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.



"aminer" <aminer@videotron.ca> wrote in message 
news:k2q0ij$rrt$1@dont-email.me...
> Hello,
>
>
> Distributed Reader-Writer Mutex 1.0
>
>
> Description:
>
> Distributed Reader-Writer Mutex, ported by Amine Moulay Ramdane
> from the Dmitry Vyukov C++ Distributed Reader-Writer Mutex to
> Object Pascal, 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
> nowboth 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.
>
>
> 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.
>
> 

[toc] | [prev] | [next] | [standalone]


#1068

From"aminer" <aminer@videotron.ca>
Date2012-09-13 15:22 -0500
Message-ID<k2tbp1$hn8$1@dont-email.me>
In reply to#1059
Hello,

I don't think i have to align on cache line bounderies the array
elements, like have done  Dmitry Vyukov, i have just added a
cache line padding  inside TOmniMREW of Omnithread, and it
has worked perfectly.

You can download Distributed Reader-Writer Mutex 1.03 from:

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


Thank you,
Amien Moulay Ramdane.





"aminer" <aminer@videotron.ca> wrote in message 
news:k2q0ij$rrt$1@dont-email.me...
> Hello,
>
>
> Distributed Reader-Writer Mutex 1.0
>
>
> Description:
>
> Distributed Reader-Writer Mutex, ported by Amine Moulay Ramdane
> from the Dmitry Vyukov C++ Distributed Reader-Writer Mutex to
> Object Pascal, 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
> nowboth 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.
>
>
> 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.
>
> 

[toc] | [prev] | [next] | [standalone]


#1069

From"aminer" <aminer@videotron.ca>
Date2012-09-13 15:31 -0500
Message-ID<k2tcbe$lmv$1@dont-email.me>
In reply to#1059
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:k2q0ij$rrt$1@dont-email.me...
> Hello,
>
>
> Distributed Reader-Writer Mutex 1.0
>
>
> Description:
>
> Distributed Reader-Writer Mutex, ported by Amine Moulay Ramdane
> from the Dmitry Vyukov C++ Distributed Reader-Writer Mutex to
> Object Pascal, 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
> nowboth 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.
>
>
> 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.
>
> 

[toc] | [prev] | [next] | [standalone]


#1070

From"aminer" <aminer@videotron.ca>
Date2012-09-13 15:51 -0500
Message-ID<k2tdh6$tag$1@dont-email.me>
In reply to#1059
Hello again,


If you have noticed , there is still a weakness with the Dmitry Vyukov
C++ Distributed Reader-Writer Mutex, cause since he is using
GetCurrentProcessorNumber() he is limiting the array of rwlocks
to the number of avaiblable cores and this is not good i think , cause
if you have many more threads than the avaiblable cores and there is
high contention this will cause the performance to degrade, so i have
decided to change that in implementation and i have used a variable
number of rwlocks/MREWs so that you can lower more the contention
and this is better for scalability.


You can download Distributed Reader-Writer Mutex 1.03 from:

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



Thank you,
Amine Moulay Ramdane





"aminer" <aminer@videotron.ca> wrote in message 
news:k2q0ij$rrt$1@dont-email.me...
> Hello,
>
>
> Distributed Reader-Writer Mutex 1.0
>
>
> Description:
>
> Distributed Reader-Writer Mutex, ported by Amine Moulay Ramdane
> from the Dmitry Vyukov C++ Distributed Reader-Writer Mutex to
> Object Pascal, 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
> nowboth 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.
>
>
> 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.
>
> 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming.threads


csiph-web