From: tbray@opentext.com (Tim Bray)
Subject: Shared read-only memory documented anywhere?
Date: 1995/07/19 [thread overview]
Message-ID: <tbray.1.300D416E@opentext.com> (raw)
Hi; I'd be delighted with an RTFM pointing at a FAQ or a place in the docs.
I have a program that (a) loads up a bunch of in-memory data structures,
and then (b) repeatedly forks and does things in the child process,
accessing the data structures read-only. (It's a modified httpd, for those
who know about such things). My alpha is spending too much time in system
mode, and I suspect these structures. So this leads to the questions:
(1) after a fork(), is OSF doing a copy-on-ref or a copy-on-write of these
things?
(2) In the case where it's doing a copy-on-ref (which I *don't* want/need),
would putting the stuff in a buffer defined as follows allow child
processes to access it without copying? And (for people who are *really*
in the know) would this make any difference?
buf = mmap(NULL, as_much_room_as_I_need,
PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_VARIABLE|MAP_SHARED,
-1, 0);
/* copy it in */
/* make it read-only; we hope that this won't get copied on fork() */
mprotect(buf, as_much_room_as_I_need, PROT_READ);
I kind of doubt that the answer is of general interest; if you
agree, email me; or post if you think anyone cares.
Thanks in advance,
Tim Bray, Open Text Corporation (tbray@opentext.com)
reply other threads:[~1995-07-19 4:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox