[Insight-developers] multithreading update w/example code
Miller, James V (Research)
millerjv@crd.ge.com
Mon, 22 Apr 2002 15:32:46 -0400
I was able to duplicate the problem on a dual processor
WinNT system.
Here's the rub: the Win32OutputWindow is deadlocking when
multiple threads write at the same time. This is occuring
because you have DebugOn() on the GradientImageFilter.
Turning DebugOff() on the GradientImageFilter and the program
works fine for me.
-----Original Message-----
From: Damion Shelton [mailto:dmshelto@andrew.cmu.edu]
Sent: Monday, April 22, 2002 1:47 PM
To: insight-developers@public.kitware.com
Subject: [Insight-developers] multithreading update w/example code
Hi,
In our continuing efforts to track down the multithreading weirdness with a
dual Athlon XP machine, we've narrowed our test code down to the following
example, which does not include any of our own code.
Based on the debug output, it looks like it hangs in the gradient filter.
By "hangs", we mean that the processor usage drops to 0% and the program
never returns.
Any ideas, please let us know. We can check this in as
"itkMultithreadingTest" or something similar if that would be a help in
diagnosing the problem.
Thanks,
Damion and Wilson
------
#include <stdio.h>
// Basic ITK stuff
#include "itkSize.h"
#include "itkIndex.h"
#include "itkImage.h"
#include "itkImageRegionIterator.h"
#include "itkPoint.h"
#include "itkShrinkImageFilter.h"
#include "itkGradientImageFilter.h"
// Image file reading
#include "itkImageFileReader.h"
#include "itkMetaImageIOFactory.h"
// Main for testing BloxImage/BloxPixel storage
void main()
{
const unsigned int dim = 3;
// Image typedef
typedef itk::Image< unsigned char, dim > TImageType;
typedef itk::ImageFileReader<TImageType> ImageFileReaderType;
// The input file reader
ImageFileReaderType::Pointer reader;
//set up the reader and register the possible types
reader = ImageFileReaderType::New();
reader->DebugOn();
itk::MetaImageIOFactory::RegisterOneFactory();
reader->SetFileName("d:/brainweb/brainweb1.mha");
reader->GetOutput()->SetRequestedRegionToLargestPossibleRegion();
reader->Update();
// Shrink by a factor of 2
typedef itk::ShrinkImageFilter<TImageType, TImageType> ShrinkType;
ShrinkType::Pointer pShrink = ShrinkType::New();
pShrink->SetShrinkFactors(2);
pShrink->SetInput( reader->GetOutput() );
// Create a gradient filter
typedef itk::GradientImageFilter<TImageType> TGradientFilter;
TGradientFilter::Pointer gradFilter = TGradientFilter::New();
gradFilter->DebugOn();
gradFilter->SetInput( pShrink->GetOutput() );
// Run the whole pipeline
gradFilter->Update();
// Get the output of the pipeline
TGradientFilter::OutputImageType::Pointer gradOutput =
gradFilter->GetOutput();
}
_______________________________________________
Insight-developers mailing list
Insight-developers@public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers