A SERVICE OF

logo

148
Chapter 13: Multiprocessing
Thread Parameters
Thread-related parameters include the following csThread methods:
numProcessors()returns the number of usable processors on the system.
setStackSize()sets the stack size to be used for this thread when it starts.
Exiting Threads
A thread only terminates execution when it calls csThread::exit() on itself. Cosmo 3D
does not support termination of threads by other threads.
Additional Thread Controls
The following csThread methods control the execution of threads:
sleep()suspends the calling thread for the number of microseconds specied in
the argument.
wait()waits for this thread to terminate.
Thread Blocking
In general, a Cosmo 3D application has two kinds of threads:
The application thread, which handles events and creates draw threads.
Multiple draw threads, which render different views of the scene graph.
In general, when one kind of thread is active, the other must be blocked. So while the
application thread handles events and modies the scene graph, the draw threads must
be blocked and, conversely, while the draw threads are active, the application thread
must be blocked from modifying the scene graph, as shown in Figure 13-2.