Hi Bram,

I don't use Windows so can't comment on specific of windows threading,
we have OpenThreads to hide all that platform specific stuff :-)

In general with threading, if you are seeing a drop in performance
it's likely to due to contention for resources, be it CPU cores,
cache, memory bandwidth etc.  Manging CPU priorities and thread
affinity are two ways to manage the threads so they don't contend so
much.

There is lots more besides to performance optimization, but it's a
huge topic and there an many unknowns for us w.r.t what you hardware,
set up, program and requirements it's rather impossible to provide
specific advice.

Robert.

On 24 February 2013 15:36, Bram Vaessen <[email protected]> wrote:
> Hi,
>
> I am porting a small project that is still in starting stages from using 
> irrlicht to osg (because osg seems more professional)
> However I encountered a problem:
>
> I'm using some custom multithreading (windows thread + mutex + event), to 
> start a second thread that handles the generation and/or loading of chunks, 
> so that the main thread can keep running at normal speed. I have CPU cores in 
> my PC.
>
> Now it used to work fine, the chunks would generate/load without slowing down 
> the rendering etc. of the main thread, but currently when using OSG the main 
> thread slows down when the second thread is generating/loading chunks.
>
> So it seems that it does not run it in a seperate thread at all, or that it 
> runs it at the same core or something. Any idea why this is, or what I could 
> do to check things, or fix it?
>
>
> Code:
> chunkRequest_mutex = CreateMutex( NULL,    // no security attributes
>                                                         false,   // BOOL 
> bInitialOwner, we don't want the
>                                                                               
>   // thread that creates the mutex to
>                                                                               
>   // immediately own it.
>                                                         "ChunkRequestMutex" 
> // lpName
>                                                         );
>         if ( chunkRequest_mutex == NULL )
>         {
>                 OutputDebugString("CreateMutex() failed for request\n" );
>         }
>         else OutputDebugString("CreateMutex() success for request\n" );
>
>         chunkRequest_event = CreateEvent( NULL,     // no security attributes
>                                                 FALSE,    // auto-reset event
>                                                 FALSE,    // initial state is 
> non-signaled
>                                                 "ChunkRequestEvent" );    // 
> lpName
>
>         if (chunkRequest_event == NULL)
>         {
>                 OutputDebugString("CreateEvent() failed for request\n");
>         }
>         else OutputDebugString("CreateEvent() success for request\n" );
>
>
>         chunkCreated_mutex = CreateMutex( NULL,    // no security attributes
>                                                         false,   // BOOL 
> bInitialOwner, we don't want the
>                                                                               
>   // thread that creates the mutex to
>                                                                               
>   // immediately own it.
>                                                         "ChunkCreatedMutex" 
> // lpName
>                                                         );
>         if ( chunkRequest_mutex == NULL )
>         {
>                 OutputDebugString("CreateMutex() 2 failed for request\n" );
>         }
>         else OutputDebugString("CreateMutex() 2 success for request\n" );
>
>
>         //create and start thread
>         HANDLE   chunkHandle;
>     unsigned  chunkThreadID;
>
>
>         DWORD   dwExitCode;
>
>         chunkHandle = (HANDLE)_beginthreadex( NULL,
>                                           0,
>                                           handleChunkRequests,
>                                           NULL,
>                                           CREATE_SUSPENDED, // so we can 
> later call ResumeThread()
>                                           &chunkThreadID );
>
>     if ( chunkHandle == 0 )
>         printf("Failed to create consumer thread\n");
>
>     GetExitCodeThread( chunkHandle, &dwExitCode );  // should be STILL_ACTIVE 
> = 0x00000103 = 259
>     printf( "initial Consumer thread exit code = %u\n", dwExitCode );
>
>
>     ResumeThread( chunkHandle );   //
>
>
>
> Thank you!
>
> Cheers,
> Bram
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=52842#52842
>
>
>
>
>
> _______________________________________________
> 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

Reply via email to