Cow

I, too, once dated a vegetarian. We had a fairly easy truce most of the time; early on in our relationship, she insisted that we go to a farm and actually spend some time with a cow, convinced that that would ensure I would never be able to eat them again. In return, she swore, she'd never bother me about it again (unless I did something like cook spam in her kitchen).

So, off we went. We found a likely looking pasture, and sure enough, there was a likely looking cow in the middle of it. Actually, there were like forty of them. After ten minutes of making extremely amusing faces and noises, she managed to tickle the curiosity of one of the thickheadedbehemoths enough that it ambled over, still chewing.

She proceeded to scratch its nose, rub its head, talk babytalk to it, etc. Your general disgusting stuff. Then she waved me over. I ambled up to the fence, leaned over, inhaled the rich smell of cowflop, and gazed at the cow.

Then it spoke. I swear it. I heard the voice, and it was rich and smooth and mellifluous, precisely the kind of wise yet simple deep tone you would expect from such a large and placid creature. And as I looked into its shallow eyes (they weren't that deep) it said, in a clear voice,

"Eat me."

And to this day, I get hungry just looking at cows wandering by. I must be iron deficient or something.

Perhaps, however, this love of cows ingrained in the human psyche is not so unusual after all. They give us beef to eat. They give us milk to drink. They give us leather to wear. And all while keeping the world turning, they walk peacefully around their fields with a eternally blissful look.

All right, I'll add some meat to this rant: Thursday, June 9, in the year 2005: Nigerian police arrest a cow accused of killing a bus driver. Apparently, while the man was urinating (urinating, for chrisakes...talk about kicking a man when he's down), the cow came from behind and knocked him to the ground. Once down, the mad bovid trampled and gored the man to death. Like you really needed more proof...

Unfortunately, this is very wasteful both of (virtual) memory and of CPU time. Typically, a large proportion of memory remains unchanged in both processes, so there is no need to copy it. In particular, in the fork() then exec*()paradigm (used to run a new program) the child process writes almost nothing before clearing all its virtual memory space with the new program. So copying is inherently wasteful.

A better solution is to share all pages, but to mark writable pages as unwritable but copy on write. When (IF) either tine tries to write to such a page, the OS is notified (it's unwritable) with a page fault. The OS can then make a fresh writable (unshared) copy of the page and map it into the writing process' address space instead of the faulting page. (Depending on how many other processes share the original page, that too may become unshared writable).

Time spent fork()ing the new process is still linear in the size of the process' memory space, but with a much smaller constant multiplier: instead of copying each page, it only needs to be marked copy on write (and, typically, a reference count set). Generally, the results are highly beneficial.