how can we wake up some process which is scheduled?

2011-12-13 Thread loody
hi all:
There is a kernel API, schedule_timeout_interruptible.
since it has the name interruptible, who and how can we interrupt this task?
suppose A use schedule_timeout_interruptible for 20s period and B
found something and he want to wake up A within this 20s period.

-- 
Regards,

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: how can we wake up some process which is scheduled?

2011-12-13 Thread Alexandru Juncu
On Tue, Dec 13, 2011 at 10:44 AM, loody milo...@gmail.com wrote:
 hi all:
 There is a kernel API, schedule_timeout_interruptible.
 since it has the name interruptible, who and how can we interrupt this task?
 suppose A use schedule_timeout_interruptible for 20s period and B
 found something and he want to wake up A within this 20s period.

I think it's related to hardware interrupts, not other tasks. So a
process waiting for a timer can be interrupted by a signal (there's a
switch between process context and interrupt context).

Take a look at schedule_timeout help page [0]. Notice the
TASK_UNINTERRUPTIBLE and TASK_INTERRUPTIBLE sections.

[0] http://kernel.org/doc/htmldocs/device-drivers/API-schedule-timeout.html

-- 
Alexandru Juncu

ROSEdu
http://rosedu.org

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: how can we wake up some process which is scheduled?

2011-12-13 Thread Dave Hylands
Hi loody,

On Tue, Dec 13, 2011 at 12:44 AM, loody milo...@gmail.com wrote:

 hi all:
 There is a kernel API, schedule_timeout_interruptible.
 since it has the name interruptible, who and how can we interrupt this
 task?
 suppose A use schedule_timeout_interruptible for 20s period and B
 found something and he want to wake up A within this 20s period.


You send the task a signal. The API for doing this has a rather unfortunate
name, and is called kill from user-space.

From kernel space, you can use kill_pid_info, or kill_proc_info.
kill_pid_info is what's called to send SIGALARM when an itimer expires.

Although using signals in kernel space is fairly rare, it's typically a
user-space to kernel-space thing, not a kernel-space to kernel-space thing.

In kernel space, I would generally use something like a timed semaphore
(down_timeout).

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies