[vtkusers] Problem with vtkThreadedController::Barrier()

Sebastien Valette sebastien.valette at creatis.insa-lyon.fr
Mon Jan 23 09:40:58 EST 2006


Hi all,
I have a problem with a multithreaded program. I thought that the method 
vtkThreadedController::Barrier() was a method
to synchronize threads by stopping them until all the threads have 
reached the point were Barrier() is called.

Unfortunately, the small code provided in this message hangs. Any idea?

Thank you,
Sebastien Valette

*********code begins**************
#include <vtkThreadedController.h>

// This will be called by all processes
void MyMain( vtkMultiProcessController *controller, void *arg )
{
  int myid, numProcs;
  myid = controller->GetLocalProcessId();
  numProcs = controller->GetNumberOfProcesses();
  cout<<numProcs<<" Processes"<<endl;
 controller->Barrier();
  cout<<"Barrier Passed !"<<endl;
}


int main( int argc, char* argv[] )
{
  vtkThreadedController *controller;
  controller = vtkThreadedController::New();
  controller->Initialize(0, 0);
  controller->SetSingleMethod(MyMain, 0);
  controller->SetNumberOfProcesses(8);
  controller->SingleMethodExecute();
  controller->Finalize();
  controller->Delete();
  return 0;
}

************ Code ends**********

-- 
http://www.creatis.insa-lyon.fr/~valette/




More information about the vtkusers mailing list