From owner-freebsd-threads@FreeBSD.ORG Thu Oct 6 17:16:05 2005 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7D18E16A41F for ; Thu, 6 Oct 2005 17:16:05 +0000 (GMT) (envelope-from Mikhail.Teterin@murex.com) Received: from blue.virtual-estates.net (aldan.algebra.com [216.254.65.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id 43F6643D49 for ; Thu, 6 Oct 2005 17:16:02 +0000 (GMT) (envelope-from Mikhail.Teterin@murex.com) Received: from corbulon.video-collage.com (static-151-204-231-237.bos.east.verizon.net [151.204.231.237]) by blue.virtual-estates.net (8.13.4/8.13.4) with ESMTP id j96HFvTg032958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Oct 2005 13:16:01 -0400 (EDT) (envelope-from Mikhail.Teterin@murex.com) Received: from mteterin.us.murex.com (195-11.customer.cloud9.net [168.100.195.11]) by corbulon.video-collage.com (8.13.4/8.13.1) with ESMTP id j96HFpEG092945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 6 Oct 2005 13:15:52 -0400 (EDT) (envelope-from Mikhail.Teterin@murex.com) Received: from mteterin.us.murex.com (mteterin@localhost [127.0.0.1]) by mteterin.us.murex.com (8.13.3/8.13.3) with ESMTP id j96HFjxZ096756; Thu, 6 Oct 2005 13:15:45 -0400 (EDT) (envelope-from Mikhail.Teterin@murex.com) Received: from localhost (localhost [[UNIX: localhost]]) by mteterin.us.murex.com (8.13.3/8.13.3/Submit) id j96HFh2B096755; Thu, 6 Oct 2005 13:15:43 -0400 (EDT) (envelope-from Mikhail.Teterin@murex.com) X-Authentication-Warning: mteterin.us.murex.com: mteterin set sender to Mikhail.Teterin@murex.com using -f From: Mikhail Teterin Organization: Murex North America To: Jason Evans Date: Thu, 6 Oct 2005 13:15:43 -0400 User-Agent: KMail/1.8.2 References: <200510050202.36730@aldan> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-u" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200510061315.43692.Mikhail.Teterin@murex.com> X-Virus-Scanned: ClamAV devel-20050525/1115/Thu Oct 6 01:42:22 2005 on corbulon.video-collage.com X-Virus-Status: Clean X-Scanned-By: MIMEDefang 2.43 Cc: threads@freebsd.org, jim@corebsd.or.id Subject: Re: Non-threaded app dlopen-ing a thread-using library X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Oct 2005 17:16:05 -0000 четвер 06 жовтень 2005 04:55, Jason Evans Ви написали: > On Oct 4, 2005, at 11:02 PM, Mikhail Teterin wrote: > > Do I need to make the executable itself multi-threaded -- just in case > > it needs to dlopen() a thread-using library, or is there a better way? > > As long as the dlopen()ed library is correctly linked, your app > doesn't need to explicitly link against the library's dependencies. > Dependencies should get pulled in after dlopen() as necessary, on the > fly, as a result of the dlopen()ed library's dependencies. What is the correct way to link a shared object, that uses threads? Using `-pthread' does not seem to change the output of ldd and a non-threaded executable is unable to dlopen() such an object. And for good reason -- the thread-implementation is decided at startup time, not at link-time, is not it? > There's nothing magical about a threaded app, as compared to a non- > threaded app. The first time a pthreads API is called, libpthread > initializes itself. It's fine if this happens as the result of > executing dlopen()ed code; the only issue is making sure that the > library dependencies are set up correctly. So, what happens, when a main executable calls some libc function directly, oblivious to the pthread-wrapper around it, that the dlopen-ed library's code is using? Thanks, -mi