Q: Multithreading ???

Matthew Hall mahall at math.uiuc.edu
Mon Jul 5 17:21:24 EDT 1999


Audrius Stundzia wrote:
> 
> Dear vtker's
> 
> First, thanks to everyone who helped me with my
> "Isosurface pipeline" question.
> 
> I now have two vtk pipelines I'd like to run independently
> as seperate threads. The first is a 2D image slice display
> and the second is a 3D isosurface extraction. Each should
> run in its own window with its own interactor.
> 
> It seems to me that I need threads to do this.
> 
> I'm used thread extensively in Java, but Unix threads
> are new to me.
> 
> Any pointers and / or sample code would be most appreciated.
> 
> Regards,
> 
> Audrius Stundzia
> 
> IBMG

Hello-
If you want a easy, quick way to do it, you could try using fork()
instead of
pthreads, sprocs or whatever. After the fork call, set up the two
different
pipelines (if fork returns 0, you are in the child process, if >0, you
are
in the parent. If <0, an error occurred)
so for example:

main(void){
        pid_t mypid;
        mypid=fork();
        if (mypid<0) <send error msg and abort>;
        else if (mypid==0){
                <set up one pipeline>
                iren->Start();
        }
        else {
                <set up the other pipeline>
                iren->Start();
        }
}

If you have two or more processors, the above will be handy, because it
will useboth. It is kind of a hack, and not too cheap memory wise.

-matt


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list