From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,ddd3ed6387461be7,start X-Google-Attributes: gidfee84,public From: tbray@opentext.com (Tim Bray) Subject: Shared read-only memory documented anywhere? Date: 1995/07/19 Message-ID: #1/1 X-Deja-AN: 106587443 organization: Open Text Corporation newsgroups: comp.unix.osf.osf1 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)