From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f72b0,db9f775c28e31eb6 X-Google-Attributes: gidf72b0,public X-Google-Thread: fe1d2,db9f775c28e31eb6 X-Google-Attributes: gidfe1d2,public X-Google-Thread: f678f,db9f775c28e31eb6 X-Google-Attributes: gidf678f,public X-Google-Thread: 115614,db9f775c28e31eb6 X-Google-Attributes: gid115614,public From: andrewg@microlise.co.uk (Andrew Gierth) Subject: Re: fork() with copy-on-write? Date: 1996/03/28 Message-ID: <4jf18a$28f@microl4.microlise.UUCP>#1/1 X-Deja-AN: 144813221 x-nntp-posting-host: microl.demon.co.uk references: <1996Mar19.160747.116289@kuhub.cc.ukans.edu> <4is3hq$fj1@microl4.microlise.UUCP> <4j8414$smu@garotte.va.pubnix.com> <4j9bqr$q1h@microl4.microlise.UUCP> <4jc6gf$3j1@bayonne.netapp.com> organization: Microlise Engineering Ltd. reply-to: andrewg@microlise.co.uk (Andrew Gierth) newsgroups: comp.unix.aix,comp.unix.misc,comp.unix.osf.misc,comp.unix.sco.misc In <4jc6gf$3j1@bayonne.netapp.com>, guy@netapp.com (Guy Harris) writes: >Furthermore, AIX, at least, supports shared memory and shared libraries >and shared text on RS/6000's with inverted page tables; it *is* possible >to have a page mapped to multiple addresses - the trick, as I remember, >is that a 32-bit per-process virtual address has the upper few bits >select a segment register, and some stuff in the segment register and >the rest of the 32-bit virtual address are concatenated to make a >>32-bit *global* virtual address. A shared page has, I think, only one >such global virtual address, but appears in more than one per-process >32-bit address space. Essentially correct, but not entirely complete... Shared stuff on the RS is divided into 2 categories, shared *segments* and shared *pages*. Segments are shared in the manner you describe, by pointing at them from the segment registers of multiple processes; that's easy. The kernel segment, kernel extension segment, shared library segment, program text segments, shared memory segments, files mapped with shmat() (an AIX-ism), are all handled like this. That gives rise to the (sometimes annoying) restriction (10, IIRC) on the number of attached shared memory segments; there are only 16 segment registers... [Another AIX-oddity is that _all_ open files are actually handled as mapped memory segments, they just aren't made addressable to the user process unless it calls shmat() on the file descriptor.] Shared pages are more difficult; if you aren't sharing the whole segment [eg. for fork() or mmap()], then as I understand it, the method used is to switch the physical page between the referencing segments as needed. So a (fast) page fault is taken on the page every time it is referenced by a different segment. [This is documented for mmap(); mmap'ed pages are shared thus between a private segment and the real shared segment that maps the file.] But in the fork() case, then at some point the page must be copied, rather than just twiddling it around; I would be interested to know whether this is on the first reference, the first write, or some other scheme. Perhaps a real AIX-wizard could enlighten us? [disclaimer: the above is all either deduction or from published IBM documentation; I have no access to the innards of AIX...] -- Andrew (andrewg@microlise.co.uk) [.sig under construction]