Quote:
Originally Posted by BlueSkull
well I was writing a code in my class for forking a child process on RedHat and I read that fork after creating child process grant 1st time stamp of CPU to newly created child process.
At home I write the same program on Ubuntu but this time parent is running first.
Is there any difference using fork in different linux distros (BSD/SystemV) or I'm misinterpreting it.
|
Neither. Some other factor is causing the difference. Does one of those systems have only one core?
Quote:
Just wana clear my doubt and also do child and parent execute simultaneously in multitasking mode or whosoever gets CPU first completes first.
|
If you have two or more cores, the user mode code will really execute simultaneously.
Most of the actual CPU time in your example is kernel code copying each line of text to the screen. Since it is the same scree, that code can't run simultaneously even if you have two cores.
After that kernel mode completes for one process in a multi core machine, the other process would have already finished the user mode code to create the next line of text, so the lines would alternate. In a single core machine, the scheduler portion of the kernel must decide which user mode code to run after each kernel operation completes. That might also make the lines alternate.