fork creates a new process and your os can choose to run them in any order it want to.
Nitpicking here:
It's undefined (and probably unpredictable on most OSs) whether the child or parent process gets scheduled first after a call to fork(). On multi-processor systems they could in theory even get scheduled at the same time.
In any case, it's misleading to call this "(running) in any order" since the processes are scheduled independently and neither is waiting on the other - for most intents and purposes they're running "simultaneously".
|