InitializeSRWLock is only supported in vista but I am looking same
feature forr XP.
Could you please suggest me notes/links/any way to do same task under
XP platform?
If it is not correct group then please let me know the right group.
Thanks & Regards,
Anand Choubey
Here is are two versions of a fairly fast rw-mutex algorithm I invented that
can be used in XP:
http://webpages.charter.net/appcore/misc/rwmutex_win_hpp.html
(has conditional read-to-write upgrade)
http://software.intel.com/en-us/forums/intel-threading-building-blocks/topic/65822/reply/87849
(has conditional read-to-write upgrade and non-conditional write-to-read
downgrade)
http://software.intel.com/en-us/forums/intel-threading-building-blocks/topic/65822
(read all...)
Here is a version that works with any IA-32 system that has semaphores
(e.g., POSIX or SysV) and either GCC or MSVC 6 or higher:
So far, I cannot get a native rw-mutex implementation (e.g., POSIX or
Solaris Threads) to beat it. Here is a little benchmark application that
caculated reads per-second on a per-thread basis:
You can test it's performance against the native read/write lock by simply
defining `USE_PTHREAD_NATIVE_RWLOCK'. Here are the results I am getting from
the test as-is on Linux Fedora Core 10. This mainly tests read performance.
Writes are VERY few and far between. So writer-to-reader contention will
probably never show up. Anyway, here is the command line I used to compile
my version:
gcc -Wall -pedantic -DNDEBUG -O3 rwmutex.c -lpthread
And here is the one I used for the NPTL:
gcc -Wall -pedantic -DNDEBUG -DUSE_PTHREAD_NATIVE_RWLOCK -O3
rwmutex.c -lpthread
Here is the relevant portion of the output I get from my version:
TEST RUN 1 of 2 RUNNING...
READERS ACHIEVED 249999 ITERATIONS PER-THREAD-PER-SECOND
TEST RUN 1 of 2 COMPLETED!!!
------------------------------------
TEST RUN 2 of 2 RUNNING...
READERS ACHIEVED 249999 ITERATIONS PER-THREAD-PER-SECOND
TEST RUN 2 of 2 COMPLETED!!!
------------------------------------
And here is the output I get from the NPTL version:
TEST RUN 1 of 2 RUNNING...
READERS ACHIEVED 133333 ITERATIONS PER-THREAD-PER-SECOND
TEST RUN 1 of 2 COMPLETED!!!
------------------------------------
TEST RUN 2 of 2 RUNNING...
READERS ACHIEVED 133333 ITERATIONS PER-THREAD-PER-SECOND
TEST RUN 2 of 2 COMPLETED!!!
------------------------------------
As you can see, my version is getting 116666 more reads
per-second-per-thread. AFAICT, that is a very significant number. Imagine if
those reads represented searches in a shared data-structure. Pretty nice
speed up over the native NPTL. Please note, I have test this under
OpenSolaris and Fedora Core 10. I have not tried it against the most recent
version of Fedora.
Enjoy!
:^D
Thanks for reply.
I am using pthread_rwlock_init api on windows. BUT issue with this api
is it takes 7 handle read lock object.
Therefore it is not good for all server applications.
http://sourceware.org/pthreads-win32/
please check above link.
Regards,
Anand Choubey
On Aug 21, 8:50 am, "Chris M. Thomasson" <n...@spam.invalid> wrote:
> "Anand Choubey" <anand.chou...@gmail.com> wrote in message
>
> news:b8d137d4-7bcb-4bdd...@i4g2000prm.googlegroups.com...
>
> > Hi,
>
> > InitializeSRWLock is only supported in vista but I am looking same
> > feature forr XP.
>
> > Could you please suggest me notes/links/any way to do same task under
> > XP platform?
>
> > If it is not correct group then please let me know the right group.
>
> Here is are two versions of a fairly fast rw-mutex algorithm I invented that
> can be used in XP:
>
> http://webpages.charter.net/appcore/misc/rwmutex_win_hpp.html
> (has conditional read-to-write upgrade)
>
> http://software.intel.com/en-us/forums/intel-threading-building-block...
> (has conditional read-to-write upgrade and non-conditional write-to-read
> downgrade)
>
> http://software.intel.com/en-us/forums/intel-threading-building-block...
> Thanks for reply.
> I am using pthread_rwlock_init api on windows. BUT issue with this api
> is it takes 7 handle read lock object.
> Therefore it is not good for all server applications.
> http://sourceware.org/pthreads-win32/
> please check above link.
For some reason I only come up with 5 HANDLE's per `pthread_rwlock_t'
object; what am I missing? Anyway, the performance of the algorithm is total
crap dog slow garbage. It's as fast as a snail trying to climb a 50,000 foot
high mountain of sea salt. The following version of my algorithm uses 3
HANDLE's per rwmutex object:
http://software.intel.com/en-us/forums/intel-threading-building-blocks/topic/65822/reply/87849
Humm... I can create code to lazily initialize them such that no HANDLES
will ever be created if there is no read-to-write contention. However,
creating a lock per-object will never really scale that good at all. It's
much better to use a hashed read/write locking scheme. Here is an example of
said scheme that I created in C:
http://groups.google.com/group/comp.programming.threads/browse_frm/thread/d6f26d54c36d4783
You can use the code to gain read/write access for any number of objects and
maintain a constant number of locks. The code compiles fine; perhaps you
should play around with it and see if it might be of use to you're server
code. Any questions you may have are welcome. BTW, the algorithm avoids the
deadlock problem inherent in other hashed locking schemes. Notice the
sorting? You can even atomically lock a number of items (e.g.,
`RWHASH_SET_DEPTH') in a single shot, without risk of deadlocking. IMVHO,
it's a VERY useful construct indeed.
Any thoughts?
Could you suggest me any test algorithm which can make sure that any
read write locks algorithm works fine.
Regards,
Anand Choubey
On Aug 21, 9:28 pm, "Chris M. Thomasson" <n...@spam.invalid> wrote:
> "Anand Choubey" <anand.chou...@gmail.com> wrote in message
>
> news:a4cc05e4-ad32-459e...@b25g2000prb.googlegroups.com...
>
> > Hi,
> > Thanks for reply.
> > I am using pthread_rwlock_init api on windows. BUT issue with this api
> > is it takes 7 handle read lock object.
> > Therefore it is not good for all server applications.
> >http://sourceware.org/pthreads-win32/
> > please check above link.
>
> For some reason I only come up with 5 HANDLE's per `pthread_rwlock_t'
> object; what am I missing? Anyway, the performance of the algorithm is total
> crap dog slow garbage. It's as fast as a snail trying to climb a 50,000 foot
> high mountain of sea salt. The following version of my algorithm uses 3
> HANDLE's per rwmutex object:
>
> http://software.intel.com/en-us/forums/intel-threading-building-block...
>
> Humm... I can create code to lazily initialize them such that no HANDLES
> will ever be created if there is no read-to-write contention. However,
> creating a lock per-object will never really scale that good at all. It's
> much better to use a hashed read/write locking scheme. Here is an example of
> said scheme that I created in C:
>
> http://groups.google.com/group/comp.programming.threads/browse_frm/th...
> Could you suggest me any test algorithm which can make sure that any
> read write locks algorithm works fine.
I always make sure to run my algorithms through Relacy Race Detector:
http://groups.google.com/group/relacy
Here is my rw-mutex algorithm implemented in Relacy:
http://relacy.pastebin.com/f3cab2025
Were you looking for a formal proof?
[...]