Messages in this thread | | | Subject | Re: fork() Problem? | Date | Wed, 5 May 1999 18:24:14 +0200 (MEST) | From | (Rogier Wolff) |
| |
David Miller wrote: > Date: Wed, 5 May 1999 09:19:54 +0300 (EEST) > From: Yavuz Selim Komur <komur@albatros.bcc.bilkent.edu.tr> > > Problem is sequence error. > > if (pid = fork()) > printf("Main Program"); > else > printf("Child Program"); > > it's clear? > > So Linux runs the child before the parent in your test runs, whereas > the opposite is true on other systems. Is this a problem?
This is a classical optimization: In 99 out of 100 cases, the "child" will perform an "exec" in a few milliseconds. The possibility is there that that will require disk IO. At that time the parent will get the chance to do its thingy: run on until the "wait" system call (about 98 percent of the cases...)
Roger.
-- ** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 ** *-- BitWizard writes Linux device drivers for any device you may have! --* ------ Microsoft SELLS you Windows, Linux GIVES you the whole house ------
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |