Hi -

I'm using OpenSG 1.6 on a project. As a single-threaded app everything 
works fine. I'm in the process of turning this into a multithreaded 
application but have run into problems.

I've poked around the archives and documentation and have found some 
references to multithreading problems. From these I get the impression 
that operations on FieldContainers from different threads can lead to 
trouble.

First of all, I'm using pthreads, not OpenSG's thread classes. My 
threads look like this:

1. main thread. Initializes OpenSG and creates an XWindowPtr, et al. 
Also creates the following threads 2-5, then waits for quit signal.
2. log thread - logging dumped to output stream periodically (no OpenSG)
3. input thread - receives input, passes to a command queue (no OpenSG)
4. window thread - watches X Window for input, may pass commands to 
command queue (uses XWindowPtr to get X display)
5. command thread - processes commands, renders scenes, (uses openSG here)

What I've noticed is that thread 4 crashes when it tries to call 
XWindowPtr->getDisplay()...... debugging the app puts the crash in 
PThreadBase::getAspect.

If I rebuild  WITHOUT thread 4 the app crashes in thread 5 once I try to 
render. Haven't traced that one yet, but some testing indicates that 
only OpenSG-related commands crash; other commands that affect 
non-OpenSG parts of the system run fine.

Now some things I've read in the docs and other threads seem to make 
some sense, but I still need help understanding this.


OpenSG 1.6 docs seem to indicate that OpenSG expects a different 
"aspect" for every FieldContainer in every thread. The tutorial 
specifically says that two (2) are created by default, and the example 
given (GLUT app) has a main thread and an animation thread. My 
application explicitly creates FieldContainers in one thread and uses 
them in at least two others, and NONE of these threads are OSGThreads! 
That would explain my crashes, I think.

Now onto possible solutions.

1) Am I required to use OpenSG Threads? If so, am I limited to just two?
2) If I limit the usage to FieldContainers to a single thread - i.e. all 
FC's are created and used in that one thread, will that work? Even if I 
use pthread_create? With a little more care I can easily segregate 
OpenSG FC's to my "command thread".....
3) The new website has a nice general discussion of threading in OpenSG. 
It alludes to changes in OpenSG 2.0 - what is the status of those 
changes? Were there improvements in OpenSG 1.8?
4) Can OpenSG be built as a single-threaded library? If so, will it buy 
me anything (like reduced overhead, improved speed, etc)? My app will 
remain multithreaded anyways..... just wondering.


Thanks,

Dan









-- 
Daniel J. Sperka, Ph. D. 
UC Davis Center for Neuroscience


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to