Asking another process sleep from another process or interrupt context
Hello List, This is what I am trying to do in linux kernel. When some event occurs; Process X wants to tell process Y to un-schedule itself(Y) [ and change state from "running or ready to run" to "not ready to run until told otherwise" ]. Process X will take care of waking up Y later. One approach probably is to set "*need_resched*" for process Y so that schedular picks another process at the first opportunity. Is there any other alternative ? Is it safe to do this from interrupt context instead of process X's context ? -- Sunil
Hey Sunil, Hope you are doing good. On Sat, Dec 1, 2012 at 6:12 AM, Sunil Agham <sunil.agham@gmail.com> wrote:
Hello List,
This is what I am trying to do in linux kernel. When some event occurs; Process X wants to tell process Y to un-schedule itself(Y) [ and change state from "running or ready to run" to "not ready to run until told otherwise" ]. Process X will take care of waking up Y later.
One approach probably is to set "*need_resched*" for process Y so that schedular picks another process at the first opportunity. Is there any other alternative ? Is it safe to do this from interrupt context instead of process X's context ?
Interrupt context is a better alternative. Make changes around the code which picks up the next process for execution. The waking up would be taken care automatically in that case. Also, this approach would be least disruptive if compared with the other alternative you listed out. Mulyadi, Any help?
-- Sunil
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- Regards, Sandeep. “To learn is to change. Education is a process that changes the learner.”
Hi Sandeep.... On Sat, Dec 1, 2012 at 11:50 AM, SandeepKsinha <sandeepksinha@gmail.com> wrote:
Interrupt context is a better alternative. Make changes around the code which picks up the next process for execution. The waking up would be taken care automatically in that case.
Also, this approach would be least disruptive if compared with the other alternative you listed out.
Mulyadi, Any help?
Since you "summon", then I have no other choice :) OK, I need to be careful here. If I may to clear up the things, there are two objectives here: 1. To unschedule other process.... Alright,I think the simplest one is setting need_resched to true or 1 (as you guys already found out). That's not the fastest way, but I am sure the most straight forward way. 2. To block the process until it is allowed to run... Sounds like mimic-ing SIGSTOP handler to me...... So I guess, to do the entire thing simplest way, is by sending SIGSTOP. Agree? -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
Yah, Thanks for the help Mulyadi and Sandeep. -- Sunil On Sat, Dec 1, 2012 at 10:35 AM, Mulyadi Santosa <mulyadi.santosa@gmail.com>wrote:
Hi Sandeep....
On Sat, Dec 1, 2012 at 11:50 AM, SandeepKsinha <sandeepksinha@gmail.com> wrote:
Interrupt context is a better alternative. Make changes around the code which picks up the next process for execution. The waking up would be taken care automatically in that case.
Also, this approach would be least disruptive if compared with the other alternative you listed out.
Mulyadi, Any help?
Since you "summon", then I have no other choice :)
OK, I need to be careful here. If I may to clear up the things, there are two objectives here:
1. To unschedule other process....
Alright,I think the simplest one is setting need_resched to true or 1 (as you guys already found out). That's not the fastest way, but I am sure the most straight forward way.
2. To block the process until it is allowed to run...
Sounds like mimic-ing SIGSTOP handler to me......
So I guess, to do the entire thing simplest way, is by sending SIGSTOP. Agree?
-- regards,
Mulyadi Santosa Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
participants (3)
-
Mulyadi Santosa -
SandeepKsinha -
Sunil Agham