The last operation of the completely fair scheduler that we need to consider is the hook function that
is called when new tasks are created: task_new_fair. The behavior of the function is controllable with
the parameter sysctl_sched_child_runs_first. As the name might suggest, it determined if a newly
created child process should run before the parent. This is usually beneficial, especially if the child performs
an exec system call afterward. The default setting is 1, but this can be changed via /proc/sys/
kernel/sched_child_runs_first.
Initially, the function performs the usual statistics update with update_curr and then employs the previously
discussed place_entity:
If the virtual run time of the parent (represented by curr) is less than the virtual run time of the child, this
would mean that the parent runs before the child — recall that small virtual run times favor left positions
in the red-black tree. If the child is supposed to run before the parent, the virtual run times of both need
to be swapped.
Afterward, the child is enqueued into the run queue as usual, and rescheduling is requested.