From owner-freebsd-threads@FreeBSD.ORG Wed Apr 30 19:35:45 2003 Return-Path: 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 214B237B40A for ; Wed, 30 Apr 2003 19:35:45 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 596F343F3F for ; Wed, 30 Apr 2003 19:35:44 -0700 (PDT) (envelope-from eischen@pcnet1.pcnet.com) Received: from pcnet1.pcnet.com (localhost [127.0.0.1]) by mail.pcnet.com (8.12.8/8.12.1) with ESMTP id h412ZhBg022979; Wed, 30 Apr 2003 22:35:43 -0400 (EDT) Received: from localhost (eischen@localhost)h412Zhst022974; Wed, 30 Apr 2003 22:35:43 -0400 (EDT) Date: Wed, 30 Apr 2003 22:35:43 -0400 (EDT) From: Daniel Eischen To: Terry Lambert In-Reply-To: <3EB0845A.FA34BA04@mindspring.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: threads@freebsd.org Subject: Re: Question about rtld-elf. Anyone?.. Anyone? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 May 2003 02:35:45 -0000 > Peter Wemm wrote: > > As John said, the problem is twofold. One is the symbol resolution itself, > > eg: when you access a function for the first time, a lazy binding call > > happens. He had ideas about how to make that fully reentrant. > > It doesn't need to be; the pointer update is atomic, so it's safe I don't think it is atomic. Take a look at rtld-elf.c. > for two threads in the same process at the same time (or there > would have been much more spectacular fireworks, before now), and > if it happens over a fork(), then the child process gets a stale > copy, and does the lazy binding call itself, triggering a COW in > the page where the lazy-bound verion should have been. Either way, > it still works (you just get an extra page in the child that you > wouldn't have had, had you waited). It works in libc_r because libc_r uses signals for its scheduling quantum and rtld masks out signals while holding write locks. It works in libthr (I'm assuming) because the kernel doesn't use POSIX scheduling and always makes sure each thread gets quantum. -- Dan Eischen