Page 2 of 2

Re: Fork in linux

Posted: Wed Jul 30, 2008 12:58 pm
by bewing
Of course, it's also true that fork() is really a cheap, kludgy way of creating a new process. Even without having to create an entire copy of the virtual userspace, that function has a tremendous amount of unneeded overhead. Most of the time, a fork is followed by an exec -- and all this fancy process duplication is worthless. The rest of the time, the only reason you need the fork is to make stdin/stdout pipes work properly. And even then, stdin/stdout pipes are not convenient on a GUI system, and are not often used anymore (in an absolute sense).

If you build GUI OS with a replacement for fork that makes input/output redirection work (ie. the filedescriptor table can get copied into the new process), but that doesn't copy anything else -- then you can forget about fork entirely.

Re: Fork in linux

Posted: Thu Jul 31, 2008 2:49 am
by jal
bewing wrote:Of course, it's also true that fork() is really a cheap, kludgy way of creating a new process. Even without having to create an entire copy of the virtual userspace, that function has a tremendous amount of unneeded overhead. Most of the time, a fork is followed by an exec -- and all this fancy process duplication is worthless.
Indeed, I always wondered about that one, since UNIX ran on a very limited computer (certainly given today's standards), and to execute a program the shell had to go through a giant waste of overhead...


JAL

Re: Fork in linux

Posted: Thu Jul 31, 2008 2:53 am
by jal
jnc100 wrote:As I recall, at least for 8086 Minix, that (segments) is exactly how they do it. I presume it means you can't use far pointers though.
Iirc, Minux did indeed not allow for any programs to be larger than 64KB.


JAL