Hi nelson,
i remeber a problem i got long time ago with openthreads and windows, even
on a 32 bit system. i located that we go an issue on windows system with the
sleep method. (windows native).
so can you try following:
(1) replace the microsleep with the
OpenThreads::Thread::YieldCurrentThread()
report what happens
(2) replce the microsleep only in the Thread class / method with
YieldCurrentThread
report what happens
if both test are also negative, then replace microsleep with
void millisleep( unsigned int milliseconds )
{
# ifdef _MSC_VER // If its Visual C++ call Win32 Sleep function
::Sleep( milliseconds);
#else // Else assume a UNIX/Linux system with nanosleep function
timespec ts;
ts.tv_sec = milliseconds / 1000;
ts.tv_nsec = (milliseconds - ts.tv_sec*1000) * 1000000;
::nanosleep(&ts, NULL);
# endif
}
what happens ?
Have also a look into:
and search in google with adrian egli / openthreads / sleep
http://www.openscenegraph.org/projects/osg/changeset/5313
2008/5/28 Cysneros, Nelson SPAWAR <[EMAIL PROTECTED]>:
>
>
> I'm having a problem with an existing application that runs well on a
> 32-bit windows XP (VS 2003) system, but does not seem to work when ran
> on a 64-bit windows XP (VS 2003) system.
>
> I narrowed down the problem to Openthreads, seems that my threaded while
> loop never (or rarely) gets called. I was able to recreate the problem
> with this simple program below. It runs two threads, both printing a
> message to the screen. Only one message is displayed on a 64bit
> machine. I turned on OSG notification to DEBUG, but no extra
> information is displayed.
>
> Has anyone else experience this problem? Am I doing something wrong?
> Thanks in advance.
>
>
> ///////////////////////////////////////
> //Header file MutexTest.h
> ///////////////////////////////////////
> #ifndef __MUTEXTEST_H_
> #define __MUTEXTEST_H_
>
> #include <OpenThreads/Thread>
> #include <OpenThreads/Mutex>
> #include <OpenThreads/Barrier>
> #include <OpenThreads/Block>
> #include <OpenThreads/ScopedLock>
> #include <iostream>
>
> class MutexTest : public OpenThreads::Thread
> {
> public:
> MutexTest();
> ~MutexTest();
> //Functions
> virtual void run();
> void quit();
> void printHello();
> void setMutex(OpenThreads::Mutex* newValue);
> OpenThreads::Mutex* getMutex();
>
> private:
> mutable OpenThreads::Mutex* _mutex;
> };
> #endif
>
>
> ///////////////////////////////////////////////////////////////////
> //Source file MutexTest.cpp
> ///////////////////////////////////////////////////////////////////
>
> #include "MutexTest.h"
>
> MutexTest::MutexTest(){
> _mutex = new OpenThreads::Mutex();
> }
>
> MutexTest::~MutexTest(){
> std::cout<<"MutexTest Test Shuting
> down....."<<std::endl;
> }
>
> void MutexTest::setMutex(OpenThreads::Mutex* newValue){
> _mutex = newValue;
> }
>
> OpenThreads::Mutex* MutexTest::getMutex(){
> return _mutex;
> }
>
> void MutexTest::quit() {
>
> }
>
> void MutexTest::printHello(){
> OpenThreads::ScopedLock<OpenThreads::Mutex>
> lock(*_mutex);
> std::cout<<"-- Mutex Class: Hello --"<<std::endl;
> }
>
> void MutexTest::run() {
> while(true){
>
>
> //////////////////////////////////////////////////////////
> //This only gets called once when running on 64bit
> system
>
> /////////////////////////////////////////////////////////
> printHello();
> //sleep
> OpenThreads::Thread::microSleep(5000);
> }//while
> }//run
>
> //
> ------------------------------------------------------------------------
> ---
> //
> // main
> //
> //
> ------------------------------------------------------------------------
> ---
> int main(int argC, char* argV[])
> {
> //Create a mutex we can share
> OpenThreads::Mutex* mutable my_mutex = new OpenThreads::Mutex;
> MutexTest* testMutex = new MutexTest();
> testMutex->setMutex(my_mutex);
>
> //Start thread
> testMutex->start();
>
> while(true)
> {
> OpenThreads::ScopedLock<OpenThreads::Mutex>
> lock(*my_mutex);
> std::cout<<"<<< Main: Hello >>>"<<std::endl;
> //sleep
> OpenThreads::Thread::microSleep(2000);
>
> }//while
> return 0;
> }//main
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
--
********************************************
Adrian Egli
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org