[comp.arch] Copy-On-Write

crowl@cs.rochester.edu (Lawrence Crowl) (03/07/90)

In article <37774@cornell.UUCP> huff@cs.cornell.edu (Richard Huff) writes:
>The true issue is supporting Copy-On-Write, which appears to be a Holy COW
>:-) among some people; this feature does NOT >involve logically sharing data
>--- it involves physically sharing data pages to represent logically distinct
>data, until someone breaks the illusion with a write access.  I'd call that a
>hack!

Copy-on-write is no more of a hack than caching.  Both improve performance
while preserving a simple computational model.  In the case of copy-on-write,
we avoid a lot of unecessary copying.

>Can anyone name a use for copy-on-write that wasn't designed to fix [small
>disjoint address spaces], [TLB/cache flush/reload penalty on context
>switch], or to support the brain dead policies of fork()?

Reasons for copy-on-write become most compelling in systems that provide a
single-level store.  In a single-level store, the entire disk is backing store
for a persistent virtual memory.  Some of these reasons can be addressed with
user-level code, but then isn't it better if the system does it automatically?
Some of the uses for copy-on-write include:

    Sending very large messages between processes on the same machine.
    Initialized data segments.
    Editor buffer initialization.
    Process forking.  (There are legitimate reasons for Unix fork(), however
       the common use of fork() is not legitimate.)
    Everyone saving their own copy of news articles :-).

>In addition, by banning virtual address aliasing [in HP's MPE XL], we can
>support virtually addressed caches, which can be accessed in parallel with
>the TLB.

This appears to be a common misconception.  One CAN use copy-on-write with
virtually addressed caches.  The number of copies in the cache is unimportant,
because (a) they reflect the logically separate copy and (b) they have the
same contents.  Since a virtually addressed cache sort of implies a
write-through cache, you can ignore existing, now unaliased, entries in the
cache.  One does have to catch writes from the cache into main memory and make
a new copy of the page in main memory.
-- 
  Lawrence Crowl		716-275-9499	University of Rochester
		      crowl@cs.rochester.edu	Computer Science Department
	  ...!{ames,rutgers}!rochester!crowl	Rochester, New York,  14627