A SERVICE OF

logo

146
Chapter 13: Multiprocessing
Implementing Multiprocessing
One rule that you must follow when implementing multiprocessing is the scene graph
cannot be modied during rendering. Cosmo 3D does not provide a mechanism for
concurrent scene graph modication and drawing.
The consequence of this rule is that you must implement semaphores to block the action
of the application or draw threads.
Note: OpenGL Optimizer provides the semaphore class, opBarrier.
The following sections describe how to implement threads.
Creating Threads
For each view of the scene graph you want to display, you use a different thread. Each
thread is bound to a csWindow and a csContext.
Threads must be created using csThread. Threads created in other ways produce
unpredictable results.
A thread can only have one context attached to it at a time. Conversely, each thread that
attempts to draw must have a separate context. Unpredictable results occur if you try to
share a context with more than one thread.
A context attached to one thread cannot be used by another thread until the rst thread
releases it using csContext::releaseCurrent().