Linux Process Scheduling – Child and Parent Process Scheduling

forkinglinuxoperating systemsprocess

When child processes are created using the fork system call what is there scheduling priorities..are they same? if so will always a child process run first and then parent…or is there a manipulation to this pattern.

I have a implementation which apparently is running the parent process first.
Is this expected?

Best Answer

Please be careful to understand that priority is not the same as order of running. As a rule, when you fork a process it runs at the same priority, unless you ask for it to be lower. The order in which parent and child run is separate.

The answer is that you cannot and should not depend on the order. In many cases after forking (or using any comparable mechanism in any other operating system), the parent will continue to run before the child starts. Or not. It all depends.

If it is important, you will have to include synchronising mechanisms to control which process runs and which waits.

Related Topic