Hi Guys,
This sounds like a problem in the thread scheduler under WindowsXP
64bit, something you'll probably just have work around rather than be
able to fix it via mods to OpenThreads side.
As an experiment try setting the processor affinity on each of the
threads so that they are on different cores, this might give the
scheduler more of hint of what to do and where.
And if you have a choice of OS, perhaps WindowsXP 64 ain't the best in
the world to go for...
Robert.
On Wed, May 28, 2008 at 7:40 PM, Cysneros, Nelson SPAWAR
<[EMAIL PROTECTED]> wrote:
> Thank you for the suggestions. Here are the results:
>
> (1) replace the microsleep with the
> OpenThreads::Thread::YieldCurrentThread()
> report what happens
>
> Works a little better. seems to stay on one thread for about a minute or so
> and then jump to the next thread for about a minute and repeats.
> Still not what I was expecting where the thread jumps back and forth
> without delay.
>
> (2) replce the microsleep only in the Thread class / method with
> YieldCurrentThread
> report what happens
> About the same as #1, but the time in each thread seems to last a lot
> longer. Probably due to the microsleep time.
>
> 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 ?
>
> Seem to behave as the original application did, where only one thread is
> being called. I did however use System::Threading::Thread::Sleep instead of
> ::Sleep in order to compile.
>
> I'll take a look at the links you send and report back if I get it solved.
>
> Thanks again for your help. :)
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Adrian Egli
> OpenSceneGraph (3D)
> Sent: Tuesday, May 27, 2008 11:31 PM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] Openthreads problem on 64 bit windows system.
>
> 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
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org