From owner-freebsd-current@FreeBSD.ORG Fri Aug 20 03:56:27 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9F5F616A4CE for ; Fri, 20 Aug 2004 03:56:27 +0000 (GMT) Received: from pd2mo3so.prod.shaw.ca (shawidc-mo1.cg.shawcable.net [24.71.223.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6BA4443D1D for ; Fri, 20 Aug 2004 03:56:27 +0000 (GMT) (envelope-from gbaratto@superb.net) Received: from pd5mr7so.prod.shaw.ca (pd5mr7so-qfe3.prod.shaw.ca [10.0.141.183]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0I2Q0067P6WMT310@l-daemon> for freebsd-current@freebsd.org; Thu, 19 Aug 2004 21:26:46 -0600 (MDT) Received: from pn2ml7so.prod.shaw.ca ([10.0.121.151]) by pd5mr7so.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0I2Q00BUS6WMQKH0@pd5mr7so.prod.shaw.ca> for freebsd-current@freebsd.org; Thu, 19 Aug 2004 21:26:46 -0600 (MDT) Received: from chivas (S01060080c8118809.vc.shawcable.net [24.85.89.252]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with SMTP id <0I2Q00F8O6WMZH@l-daemon> for freebsd-current@freebsd.org; Thu, 19 Aug 2004 21:26:46 -0600 (MDT) Date: Thu, 19 Aug 2004 20:25:39 -0700 From: "Gustavo A. Baratto" To: Doug White Message-id: <099201c48665$5da6ae00$6400a8c0@chivas> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Mailer: Microsoft Outlook Express 6.00.2800.1437 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit X-Priority: 3 X-MSMail-priority: Normal References: <087b01c48635$d3ebc850$6400a8c0@chivas> <20040819191709.Q66276@carver.gumbysoft.com> cc: freebsd-current@freebsd.org Subject: Re: memory question X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2004 03:56:27 -0000 > It would be rather lame if libraries were exclusive access. :) There may > be cases where they do get their own copies. You shouldn't rely on this > behavior for any sort of memory-use calculations... Yes, I think it would be very lame too. But because of the fact you mentioned about the possibility of one process scribbling on the library pages, I was not sure the library would be shared between 2 processes in memory. Is there a rule of thumb for memory use calculations? > I suspect the next question is going to be about sharing data between > these processes :) Nope, sharing data between two processes is quite clear for me that it should not be allowed. That would seem very dangerous, as BTW: is this the correct mailing list for such question? thank you very much... ----- Original Message ----- From: "Doug White" To: "Gustavo A. Baratto" Cc: Sent: Thursday, August 19, 2004 7:25 PM Subject: Re: memory question > On Thu, 19 Aug 2004, Gustavo A. Baratto wrote: > > > This is a bit off-topic, but I haven't found this information in the freebsd > > website nor google... and this seems to be the most programmer oriented > > mailinglist > > > > If I have 2 or more different programs using the same shared library... The > > first program loads the .so at startup and keeps running. My question is > > that when the second program starts, does it have to load the .so again, or > > the memory used by the shared library will be shared between all the two > > programs? > > I'm probably off base here, and expect to get clubbed by a developer any > second. > > Technically yes, but from a fairly basic level. ld.so, the dynamic > linker, mmap()s the library to "load" it. As pages in the library are > read, they are faulted into memory. When another process mmap()s the same > file, the Vm system notices the pages for the file are already in core and > doesn't fault them back in again, assuming the programs access the same > pages. For the pruposes of resource utilization, though, both processes > are charged for the size of the library. > > Note that ld.so maps in the pages read-only(*) so there is little danger > from one process corrupting another by scribbling on the library pages. > Files mmap()ed read-write are a whole different bag. > > (*) There's probably exceptions to this for stuff like static variables. > Changing the file on disk will cause the changes to propagate to all the > processes holding mmap()s over the file. This is usually fatal for shared > libraries. > > > I know that different processes started by the same parent share the .so, > > but I wanna know if completely different programs started by different > > parents can share the same shared object. > > > > For example, if perl/DBI started from the shell, and php/mysql started from > > apache can share the same libmysqlclient.so in memory. > > It would be rather lame if libraries were exclusive access. :) There may > be cases where they do get their own copies. You shouldn't rely on this > behavior for any sort of memory-use calculations... > > I suspect the next question is going to be about sharing data between > these processes :) > > -- > Doug White | FreeBSD: The Power to Serve > dwhite@gumbysoft.com | www.FreeBSD.org > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >