Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
* fork() with copy-on-write?
@ 1996-03-19  5:00 anh
  1996-03-20  5:00 ` Yan-Song Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: anh @ 1996-03-19  5:00 UTC (permalink / raw)


Hello everyone,

If anyone know Unixes that support fork() with copy-on-write, please post 
that system name, as I am writing an application which could depend on this
feature and I would like to know the systems which support copy-on-write and
if it has to be enabled or if it is default.

Thank-you.

Anh



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: fork() with copy-on-write?
  1996-03-19  5:00 fork() with copy-on-write? anh
  1996-03-20  5:00 ` Yan-Song Chen
@ 1996-03-20  5:00 ` Jim Sullivan's Home Account
  1996-03-22  5:00 ` Peter Shenkin
  2 siblings, 0 replies; 10+ messages in thread
From: Jim Sullivan's Home Account @ 1996-03-20  5:00 UTC (permalink / raw)


In <1996Mar19.160747.116289@kuhub.cc.ukans.edu> anh@kuhub.cc.ukans.edu writes:
>
>If anyone know Unixes that support fork() with copy-on-write, please post 
>that system name, as I am writing an application which could depend on this
>feature and I would like to know the systems which support copy-on-write and
>if it has to be enabled or if it is default.
>

As a previous poster noted, most modern UNIX systems (SCO included), support
copy-on-writes with forks (although I remember working with hardware that
didn't support this, making life, and forks, hellish :-).

However, I'm curious.  What type of application would you write that 
would depend on this operating system behaviour?  Perhaps some self-modifying
code that also modifies the parent?

Inquiring minds want to know.
--
Jim Sullivan				
SCO Canada, Inc. Toronto, Ontario	 "Little things are so important
jim@sco.com, ...!uunet!scocan!jim	  and big things don't matter much"
416 960 4042 (922 8397 for fax)	 	- Moe Berg The Pursuit of Happiness
-- 
Jim Sullivan



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: fork() with copy-on-write?
  1996-03-19  5:00 fork() with copy-on-write? anh
@ 1996-03-20  5:00 ` Yan-Song Chen
  1996-03-21  5:00   ` Andrew Gierth
  1996-03-20  5:00 ` Jim Sullivan's Home Account
  1996-03-22  5:00 ` Peter Shenkin
  2 siblings, 1 reply; 10+ messages in thread
From: Yan-Song Chen @ 1996-03-20  5:00 UTC (permalink / raw)


anh@kuhub.cc.ukans.edu wrote:
: Hello everyone,

: If anyone know Unixes that support fork() with copy-on-write, please post 
: that system name, as I am writing an application which could depend on this
: feature and I would like to know the systems which support copy-on-write and
: if it has to be enabled or if it is default.
Almost all modern unix support COW fork, like Digital UNIX, Linux, ...,etc.
the only system I use does not support COW fork is ULTRIX.

: Thank-you.

: Anh

--
yansong chen
--
YChen@uh.edu



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: fork() with copy-on-write?
  1996-03-20  5:00 ` Yan-Song Chen
@ 1996-03-21  5:00   ` Andrew Gierth
  1996-03-26  5:00     ` Josh M. Osborne
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Gierth @ 1996-03-21  5:00 UTC (permalink / raw)


In <4inn3r$ffi@masala.cc.uh.edu>, phys6k@menudo.uh.edu (Yan-Song Chen) writes:
>anh@kuhub.cc.ukans.edu wrote:
>: Hello everyone,
>
>: If anyone know Unixes that support fork() with copy-on-write, please post 
>: that system name, as I am writing an application which could depend on this
>: feature and I would like to know the systems which support copy-on-write and
>: if it has to be enabled or if it is default.
>Almost all modern unix support COW fork, like Digital UNIX, Linux, ...,etc.
>the only system I use does not support COW fork is ULTRIX.

Minor correction: on some platforms it is not copy-on-write but
copy-on-reference. This is because some architectures (mainly RISC)
have trouble with mapping a physical page to multiple virtual addresses.

The only platform I know for sure does copy-on-reference is HP-UX on the
PA-RISC platform; but I suspect that AIX also does it. Anyone know?

-- Andrew  (andrewg@microlise.co.uk)

[.sig under construction]




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: fork() with copy-on-write?
  1996-03-19  5:00 fork() with copy-on-write? anh
  1996-03-20  5:00 ` Yan-Song Chen
  1996-03-20  5:00 ` Jim Sullivan's Home Account
@ 1996-03-22  5:00 ` Peter Shenkin
  2 siblings, 0 replies; 10+ messages in thread
From: Peter Shenkin @ 1996-03-22  5:00 UTC (permalink / raw)


In article <1996Mar19.160747.116289@kuhub.cc.ukans.edu>,
 <anh@kuhub.cc.ukans.edu> wrote:
>If anyone know Unixes that support fork() with copy-on-write, please post 
>that system name, as I am writing an application which could depend on this
>feature and I would like to know the systems which support copy-on-write and
>if it has to be enabled or if it is default.

SGI's IRIX uses copy-on-write.

	-P.
-- 
**************** In Memoriam, Minnie Pearl, 1913-1996, RIP *****************
*** Peter S. Shenkin, Box 768 Havemeyer Hall, Chemistry, Columbia Univ., ***
*** NY, NY  10027;  shenkin@columbia.edu;  (212)854-5143;  FAX: 678-9039 ***
*** MacroModel home page: www.cc.columbia.edu/cu/chemistry/mmod/mmod.html***



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: fork() with copy-on-write?
  1996-03-26  5:00     ` Josh M. Osborne
@ 1996-03-26  5:00       ` Andrew Gierth
  1996-03-27  5:00         ` Guy Harris
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Gierth @ 1996-03-26  5:00 UTC (permalink / raw)


In <4j8414$smu@garotte.va.pubnix.com>, stripes@va.pubnix.com (Josh M. Osborne) writes:
>In article <4is3hq$fj1@microl4.microlise.UUCP>,
>Andrew Gierth <andrewg@microlise.co.uk> wrote:
>[...]
>>Minor correction: on some platforms it is not copy-on-write but
>>copy-on-reference. This is because some architectures (mainly RISC)
>>have trouble with mapping a physical page to multiple virtual addresses.
>>
>>The only platform I know for sure does copy-on-reference is HP-UX on the
>>PA-RISC platform; but I suspect that AIX also does it. Anyone know?
>
>Minor correction to the minor correction:
>It isn't RISC archatectures that have trubble with COW so much as
>MMU's with inverted page tables.  It just so happens that the only
>2 Unix running CPUs with inverted page table MMU's happen to be
>(gennerally regarded as) RISC systems.  They also both happen to be
>IBM CPU's as well.  The IBM ROMP (as seen in the IBM RT), and the
>IBM POWER (as well as the IBM/Apple/Motorolla PowerPC).  

Minor correction to the minor correction to the minor correction:

The PA-RISC also has an inverted page table. So change 'only 2' to
'at least 3'... (I did say 'mainly RISC'...)

Another factor is caching; some architectures cache by virtual address,
to make the data available more quickly on a cache hit. I suspect that
this is usual on architectures with inverted page tables...

-- Andrew  (andrewg@microlise.co.uk)

[.sig under construction]




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: fork() with copy-on-write?
  1996-03-21  5:00   ` Andrew Gierth
@ 1996-03-26  5:00     ` Josh M. Osborne
  1996-03-26  5:00       ` Andrew Gierth
  0 siblings, 1 reply; 10+ messages in thread
From: Josh M. Osborne @ 1996-03-26  5:00 UTC (permalink / raw)


In article <4is3hq$fj1@microl4.microlise.UUCP>,
Andrew Gierth <andrewg@microlise.co.uk> wrote:
[...]
>Minor correction: on some platforms it is not copy-on-write but
>copy-on-reference. This is because some architectures (mainly RISC)
>have trouble with mapping a physical page to multiple virtual addresses.
>
>The only platform I know for sure does copy-on-reference is HP-UX on the
>PA-RISC platform; but I suspect that AIX also does it. Anyone know?

Minor correction to the minor correction:
It isn't RISC archatectures that have trubble with COW so much as
MMU's with inverted page tables.  It just so happens that the only
2 Unix running CPUs with inverted page table MMU's happen to be
(gennerally regarded as) RISC systems.  They also both happen to be
IBM CPU's as well.  The IBM ROMP (as seen in the IBM RT), and the
IBM POWER (as well as the IBM/Apple/Motorolla PowerPC).  

There may well be other inverted page table RISCs (are the HP's?
was the old Sun4c PMEG cruft in the 4/60 era of SPARCs?), but I
don't know 'em off the top of my head.  I *know* there are also
inverted page table CISC's, but I don't know which they would be.

Inverted page tables have some nice features (the table size grows
proportionally to the amount of physical memory in the machine, as
opposed to "normal" MMUs that require space proportional to the VM
size -- frequently with tricks to make the multiplyer smaller (multi
level page tables)).  Unfortunitly they have some rather irritating
side effects (of which making COW hard is only one!).

I'm only an OS & hardware dabbler, not a serious student of either of
the arts.  So I beleve I am unqualifyed to say *which* kind of MMU is
better when all the pros and cons are weighed.  Thus I will leave you
with no answer to that question.
-- 
Just another dislexic porgrammer
Not speaking for any of my employers -- whomever they may be



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: fork() with copy-on-write?
  1996-03-26  5:00       ` Andrew Gierth
@ 1996-03-27  5:00         ` Guy Harris
  1996-03-28  5:00           ` Andrew Gierth
  1996-03-28  5:00           ` Jens-Uwe Mager
  0 siblings, 2 replies; 10+ messages in thread
From: Guy Harris @ 1996-03-27  5:00 UTC (permalink / raw)


Andrew Gierth <andrewg@microlise.co.uk> wrote:
>Another factor is caching; some architectures cache by virtual address,
>to make the data available more quickly on a cache hit.

The Sun-3/2xx machines, Sun-4/2xx machines, Sun-4c machines, Auspex
machines with an HP V host processor, and probably others

	1) have virtually-indexed, virtually-tagged caches

and

	2) can run OSes that support copy-on-write and mapping a
	   physical page to multiple virtual addresses:

Some other machines from Sun, Auspex, and others, have
virtually-indexed, physically-tagged caches, and can run those OSes as
well.

And, no, the OSes in question (SunOS 4.x and 5.x) do *not* automatically
mark shared pages as uncacheable; they only do so if the virtual
addresses for the shared page aren't all congruent modulo the cache
size.

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.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: fork() with copy-on-write?
  1996-03-27  5:00         ` Guy Harris
  1996-03-28  5:00           ` Andrew Gierth
@ 1996-03-28  5:00           ` Jens-Uwe Mager
  1 sibling, 0 replies; 10+ messages in thread
From: Jens-Uwe Mager @ 1996-03-28  5:00 UTC (permalink / raw)


In article <4jc6gf$3j1@bayonne.netapp.com>, guy@netapp.com (Guy Harris) wrote:

> 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.

This works fine for the AIX way to do shared libraries and for shmat()
style shared memory. It simply makes sure that all virtual addresses are
the same by placing them in the global segment (side note: if you unload a
shared object you might still call functions in it as the global segment
is still available!).

But AIX has to go through hoops to be able to do mmap(). The following is
from the InfoExplorer database:

  The mmap subroutine provides a unique object address for each process that
  maps to an object.  The software accomplishes this by providing each process
  with a unique virtual address, known as an alias.  The shmat subroutine
  allows processes to share the addresses of the mapped objects.

  Because only one of the existing aliases for a given page in an object has a
  real address translation at any given time, only one of the mmap mappings can
  make a reference to that page without incurring a page fault.  Any reference
  to the page by a different mapping (and thus a different alias) results in a
  page fault that causes the existing real-address translation for the page to
  be invalidated.  As a result, a new translation must be established for it
  under a different alias.  Processes share pages by moving them between these
  different translations.

If one wants to access the same data with multiple processes one has to
use shmat() to avoid the fault overhead. But shmat() also has the limit of
10 mappings that can be done, as each mapping consumes one segment
register. So if you intend to map more than 10 files you will have to use
mmap() instead, which may be a problem performance wise.

The AIX global variable _system_configuration (available to any process)
has a structure member that looks promising:

        int virt_alias;         /* 1 if hardware aliasing is supported */

I hope that this one is true for some future model (it was zero for all
models I tried).

-- 
Jens-Uwe Mager

HELIOS Software GmbH
Lavesstr. 80
30159 Hannover
Phone:        +49 511 36482-0
FAX:          +49 511 36482-69



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: fork() with copy-on-write?
  1996-03-27  5:00         ` Guy Harris
@ 1996-03-28  5:00           ` Andrew Gierth
  1996-03-28  5:00           ` Jens-Uwe Mager
  1 sibling, 0 replies; 10+ messages in thread
From: Andrew Gierth @ 1996-03-28  5:00 UTC (permalink / raw)


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]




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1996-03-28  5:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-03-19  5:00 fork() with copy-on-write? anh
1996-03-20  5:00 ` Yan-Song Chen
1996-03-21  5:00   ` Andrew Gierth
1996-03-26  5:00     ` Josh M. Osborne
1996-03-26  5:00       ` Andrew Gierth
1996-03-27  5:00         ` Guy Harris
1996-03-28  5:00           ` Andrew Gierth
1996-03-28  5:00           ` Jens-Uwe Mager
1996-03-20  5:00 ` Jim Sullivan's Home Account
1996-03-22  5:00 ` Peter Shenkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox