public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* wait_event_interruptible
@ 2004-12-07  8:19 Hendrik Wiese
  2004-12-07 13:32 ` wait_event_interruptible Roland Dreier
  0 siblings, 1 reply; 3+ messages in thread
From: Hendrik Wiese @ 2004-12-07  8:19 UTC (permalink / raw)
  To: LKLM

Hello,

I created a kernel thread inside of my driver by calling the function 
kernel_thread with a function pointer. Now this thread calls daemonize 
and allow_signal and then it runs a forever loop until it is terminated 
by the kernel (unloading the driver etc). And because it is written in 
the documentation I put the thread asleep by calling 
wait_event_interruptible with a wait queue called "dpn_wq_run" inside 
the forever loop. Now is it right that a wake_up_interruptible in the 
ISR has to wake up the thread so it continues its work? If yes... why 
isn't that working for me? I called wait_event_interruptible with that 
dpn_wq_run inside the kernel thread and do a wake_up_interruptible 
inside the ISR with the same dpn_wq_run. But my kernel thread won't wake 
up. Is there anything else I have to do to the wait queue, but calling 
init_wait_queue on it?

Thanks a lot

Hendrik

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: wait_event_interruptible
  2004-12-07  8:19 wait_event_interruptible Hendrik Wiese
@ 2004-12-07 13:32 ` Roland Dreier
  2004-12-07 13:56   ` wait_event_interruptible Hendrik Wiese
  0 siblings, 1 reply; 3+ messages in thread
From: Roland Dreier @ 2004-12-07 13:32 UTC (permalink / raw)
  To: Hendrik Wiese; +Cc: LKLM

    Hendrik> Hello, I created a kernel thread inside of my driver by
    Hendrik> calling the function kernel_thread with a function
    Hendrik> pointer. Now this thread calls daemonize and allow_signal
    Hendrik> and then it runs a forever loop until it is terminated by
    Hendrik> the kernel (unloading the driver etc). And because it is
    Hendrik> written in the documentation I put the thread asleep by
    Hendrik> calling wait_event_interruptible with a wait queue called
    Hendrik> "dpn_wq_run" inside the forever loop. Now is it right
    Hendrik> that a wake_up_interruptible in the ISR has to wake up
    Hendrik> the thread so it continues its work? If yes... why isn't
    Hendrik> that working for me? I called wait_event_interruptible
    Hendrik> with that dpn_wq_run inside the kernel thread and do a
    Hendrik> wake_up_interruptible inside the ISR with the same
    Hendrik> dpn_wq_run. But my kernel thread won't wake up. Is there
    Hendrik> anything else I have to do to the wait queue, but calling
    Hendrik> init_wait_queue on it?

wait_event_interruptible() will sleep until your ISR wakes it up, but
for your thread to run, you also need to make sure that the condition
being tested by wait_event_interruptible() is true (otherwise it will
go back to sleep).  For example, if your thread does:

	wait_event_interruptible(&my_wait, work != 0);

then your ISR needs to do

	work = 1;
	wake_up_interruptible(&my_wait);

If you don't set work, the wake_up will have no effect.

 - R.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: wait_event_interruptible
  2004-12-07 13:32 ` wait_event_interruptible Roland Dreier
@ 2004-12-07 13:56   ` Hendrik Wiese
  0 siblings, 0 replies; 3+ messages in thread
From: Hendrik Wiese @ 2004-12-07 13:56 UTC (permalink / raw)
  To: Roland Dreier; +Cc: LKLM

Roland Dreier wrote:

>    Hendrik> Hello, I created a kernel thread inside of my driver by
>    Hendrik> calling the function kernel_thread with a function
>    Hendrik> pointer. Now this thread calls daemonize and allow_signal
>    Hendrik> and then it runs a forever loop until it is terminated by
>    Hendrik> the kernel (unloading the driver etc). And because it is
>    Hendrik> written in the documentation I put the thread asleep by
>    Hendrik> calling wait_event_interruptible with a wait queue called
>    Hendrik> "dpn_wq_run" inside the forever loop. Now is it right
>    Hendrik> that a wake_up_interruptible in the ISR has to wake up
>    Hendrik> the thread so it continues its work? If yes... why isn't
>    Hendrik> that working for me? I called wait_event_interruptible
>    Hendrik> with that dpn_wq_run inside the kernel thread and do a
>    Hendrik> wake_up_interruptible inside the ISR with the same
>    Hendrik> dpn_wq_run. But my kernel thread won't wake up. Is there
>    Hendrik> anything else I have to do to the wait queue, but calling
>    Hendrik> init_wait_queue on it?
>
>wait_event_interruptible() will sleep until your ISR wakes it up, but
>for your thread to run, you also need to make sure that the condition
>being tested by wait_event_interruptible() is true (otherwise it will
>go back to sleep).  For example, if your thread does:
>
>	wait_event_interruptible(&my_wait, work != 0);
>
>then your ISR needs to do
>
>	work = 1;
>	wake_up_interruptible(&my_wait);
>
>If you don't set work, the wake_up will have no effect.
>
> - R.
>
>  
>
Ah, yes. That works. Thanks a lot.

Is it the right way checking for available data inside the kernel 
thread? I experimentally put the
code that checks and reads data from the hardware from the kernel thread 
into a function
directly called by the ISR and that works too. Now what is the better 
way of receiving data?
Within the kernel thread woken up by the ISR or within the ISR itself 
(or a sub function
called by the ISR)?

Thanks again

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-12-07 13:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-07  8:19 wait_event_interruptible Hendrik Wiese
2004-12-07 13:32 ` wait_event_interruptible Roland Dreier
2004-12-07 13:56   ` wait_event_interruptible Hendrik Wiese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox