Hi,

>>>        Something fishy with osg::Barrier
>>>
>>>Attached to this mail is is a short program that stress-test
>>>osg::Barrier. At least in Win32 it fails almost immediately. If
>>>you allow some slack by introducing some sleeps in the loop, it
>>>seems to work a bit more often. (Not that that is a pretty solution
>>>though :-)
>>
>>
>> this is a pending issue. There seem to be 2 solutions but I did
>> not have time to decide which one to use.

ok, I played around with it and my current solution would be similar
to the Linux implementation. But before I commit it and change it
again, just the short question if somebody sees a loophole that
I might have missed.

inline
void WinThreadBarrierBase::enter(void)
{
    WaitForSingleObject(_pMutex1, INFINITE);

    ++_uiNumWaiters;

    if(_uiNumWaiters == _uiNumWaitFor)
    {
        ReleaseSemaphore(_pBarrierSema[_uiCurrentCond],
                         _uiNumWaitFor - 1,
                          NULL);

        _uiNumWaiters = 0;
        _uiCurrentCond = 1 - _uiCurrentCond;

        ReleaseMutex(_pMutex1);

        return;
    }
    else
    {
        HANDLE waitObjects[2] =
        {
            _pBarrierSema[_uiCurrentCond],
            _pMutex1
        };

        ReleaseMutex(_pMutex1);

        WaitForMultipleObjects(2,
                               waitObjects,
                               true,
                               INFINITE);

        ReleaseMutex(_pMutex1);
    }
}



regards,
  gerrit




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to