Hi all,
I am not quite sure if osgDB/Reentrant Mutex is threadsafe (just got
into Multithreading). Lets make a little example. Consider two Threads:
Thread one and Thread two.

Now lets make this sequence of operations:

* Normal Program Flow everything runs fine so far.
* Thread one just unlocked the Reentrant Mutex, so "_threadHoldingMutex"
is Thread one.
* Now Thread one tries to aquire the lock again by calling
"ReentrantMutex::lock()" and passes
"_threadHoldingMutex==OpenThreads::Thread::CurrentThread()"
* Now Thread two gets some time calling "ReentrantMutex::lock()" and
since _threadHoldingMutex==OpenThreads::Thread::CurrentThread() is not
true for this one it is going to lock the OpenThreads::Mutex and setting
the "_lockCount" to "1".
* Now back to the other Thread, which is passes "_lockCount > 0" now and
gets the ReentrantLock as well.

Conculsion: Both Threads aquire the lock.

Maybe solution: Setting "_threadHoldingMutex" to "0" when unlocking the
Thread.

Have a nice weekend,
Richard

 
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to