From owner-freebsd-hackers Mon Jan 12 15:40:10 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.7/8.8.7) id PAA20546 for hackers-outgoing; Mon, 12 Jan 1998 15:40:10 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp01.primenet.com (smtp01.primenet.com [206.165.6.131]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id PAA20478 for ; Mon, 12 Jan 1998 15:39:45 -0800 (PST) (envelope-from tlambert@usr08.primenet.com) Received: (from daemon@localhost) by smtp01.primenet.com (8.8.8/8.8.8) id QAA00963; Mon, 12 Jan 1998 16:39:34 -0700 (MST) Received: from usr08.primenet.com(206.165.6.208) via SMTP by smtp01.primenet.com, id smtpd000938; Mon Jan 12 16:39:29 1998 Received: (from tlambert@localhost) by usr08.primenet.com (8.8.5/8.8.5) id QAA23345; Mon, 12 Jan 1998 16:39:22 -0700 (MST) From: Terry Lambert Message-Id: <199801122339.QAA23345@usr08.primenet.com> Subject: Re: sharable static arrays? To: chrisy@flix.net (Chrisy Luke) Date: Mon, 12 Jan 1998 23:39:22 +0000 (GMT) Cc: joelh@gnu.org, freebsd-hackers@FreeBSD.ORG In-Reply-To: <19980112112455.48744@flix.net> from "Chrisy Luke" at Jan 12, 98 11:24:55 am X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk > > Are static arrays shared across multiple invocations of a program? > > Not intrinsicly. You'll have to either use SYS-V style shared > memory (options SYSVSHM SYSVSEM SYSVMSG in a kernel config and > shmget(2) etc) or use BSD style mapped memory (mmap(2)). They will be shared if your compiler puts them in your text section instead of putting them in your data section. Supposedly, GCC supports this. Actually, -fwritable-strings defeats placing static strings into your text segment (which is mapped read-only). Ideally, all static data should be mapped copy-on-write. I don't think it's mapped, at this point; it probably needs a seperate ELF section from the rest of data, to (1) force it to a page boundry for it's mapping and (2) allow it to have seperate section flags to indicate it should be treated as copy-on-write. So it's "yes, if you do it right" and "no, but probable in the not so near future if you don't do it right". Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.