[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
  Web www.spinics.net

pthread problem

Hi, folks,

Recently I downloaded a C++ threading library ZThread
2.3.1 based pthread from zthread.sourceforge.net. The
compilation and installation were smooth. But when I
used a very simiple test program 'MyThread' to try
this library, I found out that the dynamically linked
program cannot exit after all threads finish, but the
statically linked program has no such problem. And if
I use LD_ASSUME_KERNEL=2.4.19 to run the dynamical
version, the program can exit normally. On my Redhat
Enterprise Linux 3.0 (ES) system, I found out that
normally the program will use /lib/tls/libpthread.so.0
which causes the problem, and by using
LD_ASSUME_KERNEL=2.4.19, the program uses
/lib/libpthread-0.10.so which does not cause any
problem, plus the statically linked program using
/usr/lib/libpthread.a works fine too!

I am wondering what are the possible causes for this
problem? and how to fix it? Any information is greatly
appreciated! Thanks a lot!

*** System infomrations ***

All those pthread library files belong to the glibc
and glibc-devel 2.3.2-95.20. My linux kernel is Redhat
2.4.21-15, my GCC options are:

Reading specs from
Configured with: ../configure --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-shared --enable-threads=posix
--disable-checking --with-system-zlib
--enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-39)
 /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/cc1plus -v
-D__GNUC__=3 -D__GNUC_MINOR__=2
-D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__
-D__unix__ -D__gnu_linux__ -D__linux__ -D__unix
-D__linux -Asystem=posix -D__NO_INLINE__
-D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386
-Amachine=i386 -Di386 -D__i386 -D__i386__
-D__tune_i386__ foo.C -D__GNUG__=3 -D__DEPRECATED
-D__EXCEPTIONS -quiet -dumpbase foo.C -version -o
GNU CPP version 3.2.3 20030502 (Red Hat Linux
3.2.3-39) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2.3 20030502 (Red Hat Linux
3.2.3-39) (i386-redhat-linux)
        compiled by GNU C version 3.2.3 20030502 (Red
Hat Linux 3.2.3-39).
ignoring nonexistent directory
#include "..." search starts here:
#include <...> search starts here:
End of search list.
 as -V -Qy -o /tmp/ccwWhY9O.o /tmp/ccJD4yWX.s
GNU assembler version (i386-redhat-linux)
using BFD version 20030523
--eh-frame-hdr -m elf_i386 -dynamic-linker
/tmp/ccwWhY9O.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s


The source code of 'MyThread.cpp' is:

#include <iostream>
#include <cmath>
#include <zthread/Thread.h>
#include <zthread/Runnable.h>
using namespace std;
using namespace ZThread;

class MyThread : public Runnable
	int id;
	unsigned long delaying;


	MyThread(int ident = 0, unsigned long delay =
		id = ident;
		delaying = delay;
		cout << "Thread #" << id << ": " << "running" <<

		cout << "Thread #" << id << " completed" << endl;

	void run()
		double sum = 0.0;
		for(long i = 0; i < delaying; ++i) sum +=

int main(void)
	int n_threads;
	cout << "How many threads do you want: ";
	cin >> n_threads;
		for(int i = 0; i < n_threads; ++i) Thread t(new
MyThread(i, 500000L));
	} catch(Synchronization_Exception& e)
		cerr << e.what() << endl; 
	cout << "Done!" << endl;

Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!

Redhat-devel-list mailing list

[Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

Powered by Linux