[Insight-users] thread-safe containers
Benjamin King
king.benjamin at mh-hannover.de
Wed Jan 19 07:54:34 EST 2005
Hello,
I need an erosion that reports the eroded voxels. To do this, I modified
itk::ErodeObjectMorphologyImageFilter and added a std::vector<IndexType>
member variable to hold the voxel positions. I added positions in the
Evaluate() method.
Unfortunately I got protection faults when I booted my system with
hyperthreading on. The code ran fine with hyperthreading disabled, however.
I don't have much experience with thread safety, but when I added debug
messages to Evaluate(), the output seemed to be interleaved from two threads.
Can anyone tell me, if different threads can safely append to a std::vector<T>
and what I can do about it if they can't?
Some info about my system:
uname -a:
Linux luna 2.4.25-gentoo-r4 #3 SMP Fr Jun 25 12:28:45 CEST 2004 i686 Intel(R)
Pentium(R) 4 CPU 2.80GHz GenuineIntel GNU/Linux
gcc -v:
Lese Spezifikationen von /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/specs
Konfiguriert mit: /var/tmp/portage/gcc-3.3.4-r1/work/gcc-3.3.4/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++ --enable-threads=posix --enable-long-long
--disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio
--enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3
--with-local-prefix=/usr/local --enable-shared --enable-nls
--without-included-gettext --disable-multilib --enable-__cxa_atexit
--enable-clocale=generic
Thread-Modell: posix
gcc-Version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)
cheers,
Benjamin
--
Benjamin King
Institut für Medizinische Informatik
Medizinische Hochschule Hannover
Tel.: +49 511 532-2663
More information about the Insight-users
mailing list