Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Distributed Reader-Writer Mutex version 1.03

Reply
Thread Tools

Distributed Reader-Writer Mutex version 1.03

 
 
Lew
Guest
Posts: n/a
 
      09-13-2012
aminer wrote:
> Distributed Reader-Writer Mutex 1.03
>
> 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:

....
>
> 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,

....
>
> Language: FPC Pascal v2.2.0+ / Delphi 7+: http://www.freepascal.org/


Why the frak are you spamming comp.lang.java.programmer?

This is a newsgroup for *Java* programmers.

--
Lew
 
Reply With Quote
 
 
 
 
aminer
Guest
Posts: n/a
 
      09-13-2012

Hello,


Distributed Reader-Writer Mutex 1.03


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 the
Dmitry Vyukov Distributed Reader-Writer Mutex, in the first version i
have not used GetCurrentProcessor() but i have used GetCurrentThreadID(),
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.

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 is
based on the following C++ Distributed Reader-Writer Mutex by Dmitry Vyukov,
read more here:

http://www.1024cores.net/home/lock-f...r-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(100);

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(200); // here we are creating 200 MEWs

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
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() .

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..

And 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 my 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.


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 -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 version 1.03 from:

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




Thank you,
Amine Moulay Ramdane.






 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between mutex.mutex and threading.Lock sven Python 2 12-04-2009 11:30 PM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? PA Bear [MS MVP] ASP .Net 0 02-05-2008 03:28 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? V Green ASP .Net 0 02-05-2008 02:45 AM
problem mutex-thread "Unlocking mutex owned by another thread ???" NaeiKinDus C++ 3 04-15-2007 09:35 PM
problem mutex-thread "Unlocking mutex owned by another thread ???" NaeiKinDus C++ 1 04-14-2007 07:40 PM



Advertisments