
08-22-2008, 03:25 AM
|
Re: Questions about Minix "Erik van der Kouwe" few.vu.nl> wrote:
>> One could still implement copy-on-write using segmentation.
>> Only, instead of duplicating the pages as they are written, the data
>> segment needed to be duplicated all at once.
>> The only problem would be if the parent process wrote something in the
>> memory immediately after the fork().
>> (now, thinking about that, it's pretty likely that the parent does
>> that)
> In fact, it is absolutely certain that both processes will modify their
> memory. At some point they will call either exec or exit, which causes
> the return address to be pushed on the stack which would trigger a copy.
It is also very common for a program to store the result of fork() in a
variable, because you have to do two checks against the value: check for
error and check for parent/child status. The only time I have ever seen a
program that used an "if (fork()) {....} else {....}" construction (thus
not using a variable) it caused incorrect program behaviour: the fork
_did_ fail occasionally and the program could not detect it.... So, I
think it is safe to say that copy-on-write for the data/stack segment is a
nice idea but in practice not very useful 
Regards,
Jens
--
Jens de Smit
Student Computer Science | Vrije Universiteit Amsterdam jfdsmit@few.vu.nl | http://www.few.vu.nl/~jfdsmit
"[In the end, people] get furious at IT that the goddamn magic isn't working"
-- Stewart Dean |