pthread problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
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__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102
-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
/tmp/ccJD4yWX.s
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
"/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.2.3
 /usr/include/c++/3.2.3/i386-redhat-linux
 /usr/include/c++/3.2.3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/include
 /usr/include
End of search list.
 as -V -Qy -o /tmp/ccwWhY9O.o /tmp/ccJD4yWX.s
GNU assembler version 2.14.90.0.4 (i386-redhat-linux)
using BFD version 2.14.90.0.4 20030523
 /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/collect2
--eh-frame-hdr -m elf_i386 -dynamic-linker
/lib/ld-linux.so.2
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../crt1.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../crti.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/crtbegin.o
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.3
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../..
/tmp/ccwWhY9O.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s
-lgcc
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/crtend.o
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../crtn.o

===============================================

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;

  public:

	MyThread(int ident = 0, unsigned long delay =
500000L)
	{
		id = ident;
		delaying = delay;
		cout << "Thread #" << id << ": " << "running" <<
endl;
	}

	~MyThread()
	{
		cout << "Thread #" << id << " completed" << endl;
	}

	void run()
	{
		double sum = 0.0;
		for(long i = 0; i < delaying; ++i) sum +=
sin(sqrt(log((double)(i+1))));
	}
};

int main(void)
{
	int n_threads;
	cout << "How many threads do you want: ";
	cin >> n_threads;
	try
	{
		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!
http://promotions.yahoo.com/new_mail


_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/redhat-devel-list

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

  Powered by Linux