LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Even after setting 'sysctl_sched_child_runs_first' child is not scheduling firs (https://www.linuxquestions.org/questions/programming-9/even-after-setting-%27sysctl_sched_child_runs_first%27-child-is-not-scheduling-firs-4175480811/)

Ramesh KOTABAGI 10-15-2013 01:57 AM

Even after setting 'sysctl_sched_child_runs_first' child is not scheduling firs
 
Hi,

I have an application where i want my child process need to run first after fork() then parent.

Its daemon where first parent writes its pid into file in its own context then it
forks a child and exits. Then the child writes its pid into same file again in its own context using getpid().

But do the way application is designed to read the pid of daemon( child) we want
child process to schedule first before parent to update the pid into file before parent exits.

i tried by setting 'sysctl_sched_child_runs_first' to 1 still even after parent is scheduling first then child.

Same application works fine with the older kernel version 2.6.27 where 'sysctl_sched_child_runs_first' set 1.

Thanks in advance.

Here what i tried out after going through the code.

There is a conflict of implementation with comments in the kernel code.
In copy_process() during scheduler related setup (sched_fork()) for new task(child) kernel try to schedule the child if sysctl_sched_child_runs_first
is set. But just before this task state is Set to TASK_RUNNING

/*
* We mark the process as running here. This guarantees that nobody will actually run it, and a signal or other external event cannot wake it up and insert it on the runqueue either.
*/
p->state = TASK_RUNNING;

and also child not yet on the tasklist.

With 'sysctl_sched_child_runs_first' set and if i try to schedule the child first after the copy_process() done from wake_up_new_task() context(Where actually for first time kernel will try to wake up new task) it work fine.(It’s how it is done in 2.6.27 kernel).

But i don’t know why this implementation has been changed in the latest kernel versions which is actually not working as expected and breaks the earlier functionality

Regards,
Ramesh


All times are GMT -5. The time now is 06:44 PM.