LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-15-2013, 01:57 AM   #1
Ramesh KOTABAGI
LQ Newbie
 
Registered: Oct 2013
Location: Bangalore
Posts: 1

Rep: Reputation: Disabled
Post 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

Last edited by Ramesh KOTABAGI; 10-15-2013 at 04:52 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Child THREAD and Child PROCESS whho Linux - Newbie 12 02-16-2015 12:22 AM
Under which circumstances a child process creates another child process using fork? mitsulas Programming 3 12-08-2009 08:16 AM
How to kill a Child and all its subsequent child process in C shayer009 Programming 3 12-04-2007 12:40 AM
Killing a child process from another child marri Programming 6 10-01-2004 07:08 PM
re-install grub with firs cd debora Fedora 2 08-28-2004 08:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration