public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* wait_event_interruptible_timeout problem
@ 2005-09-13 13:51 manomugdha biswas
  2005-09-14  6:14 ` manomugdha biswas
  0 siblings, 1 reply; 4+ messages in thread
From: manomugdha biswas @ 2005-09-13 13:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: gaurav4lkg


 Hi,
 I have a kernel module (kernel 2.6) where I have
 opened multiple tcp connections. when there is no
 data
 i want my process to sleep. For that i have added
 the
 following code.
  
 /* Initialise the wait q head */
   init_waitqueue_head(&VNICClientWQHead);
 
 init_waitqueue_entry(&(currentMap->waitQ), current);
 add_wait_queue(currentMap->sock->sk->sk_sleep,
 &(currentMap->waitQ));
 
 /* here currentMap is a structure containing tcp
 conenction info for my module. There is a currentMap
 for each tcp connection */
 
 wait_event_interruptible_timeout(VNICClientWQHead,
                                  0, HZ * 100000);
 
 I am not sure about the condition argument, 0. 
 
 It is not working. How the condition is to be set
 here
 so that whenever data is available on any socket
 (tcp
 connection) the sleeping process gets waken up?
 
 Could anyone please give some light on this?
 
 Regards,
 Mano
 
> 
> 
> 
> 
> --- Gaurav Dhiman <gaurav4lkg@gmail.com> wrote:
> 
> > On 9/13/05, manomugdha biswas
> > <manomugdhab@yahoo.co.in> wrote:
> > > Hi,
> > > I am using the this function in the following
> way:
> > 
> > you are using it wrong way ....
> > 
> > > 
> > > wait_queue_head_t     VNICClientWQHead;
> > > 
> > > /* Initialise the wait q head */
> > > init_waitqueue_head(&VNICClientWQHead);
> > > 
> > > init_waitqueue_entry(&waitQ, current);
> > > add_wait_queue(sock->sk->sk_sleep, waitQ));
> > 
> > need not to do this at all, as all this is done by
> > wait_event_interruptible_timepout() function. Just
> > here you initialize
> > the head of the list.
> > 
> > > 
> > > /*
> > >  my code, it reads data from socket
> > > */
> > > 
> > >
> wait_event_interruptible_timeout(VNICClientWQHead,
> > 0,
> > > HZ * 100000);
> > > 
> > > if no activity is to be done then this process
> > sleeps.
> > > When some data comes in socket i.e socket
> becomes
> > > readable this process should wake up. In kernel
> > 2.4 it
> > > was working fine using
> > interruptible_sleep_on_time().
> > > But it is not working in kernel 2.6 even if data
> > > arrives in socket! The sleeping process never
> wake
> > up.
> > > Could you please tell me what is the problem?
> > > 
> > > Regards,
> > > Mano
> > > 
> > > 
> > > --- Gaurav Dhiman <gaurav4lkg@gmail.com> wrote:
> > > 
> > > > On 9/13/05, manomugdha biswas
> > > > <manomugdhab@yahoo.co.in> wrote:
> > > > > Hi,
> > > > > I was using interruptible_sleep_on_timeout()
> > in
> > > > kernel
> > > > > 2.4. In kernel 2.6 I have use
> > > > > wait_event_interruptible_timeout. But it is
> > now
> > > > > working!!. interruptible_sleep_on_timeout()
> > was
> > > > > working fine. Could anyone please help me in
> > this
> > > > > regard.
> > > >
> > > > What problem are you facing with
> > > > wait_event_interruptible_timeout() in 2.6
> > > > Elaborate more on it.
> > > >
> > > > -Gaurav
> > > >
> > > > > Regards,
> > > > > Mano
> > > > >
> > > > > Manomugdha Biswas
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
>
__________________________________________________________
> > > > > Yahoo! India Matrimony: Find your partner
> now.
> > Go
> > > > to http://yahoo.shaadi.com
> > > > > -
> > > > > To unsubscribe from this list: send the line
> > > > "unsubscribe linux-kernel" in
> > > > > the body of a message to
> > majordomo@vger.kernel.org
> > > > > More majordomo info at
> > > > http://vger.kernel.org/majordomo-info.html
> > > > > Please read the FAQ at 
> > http://www.tux.org/lkml/
> > > > >
> > > >
> > > >
> > > > --
> > > > - Gaurav
> > > > my blog: http://lkdp.blogspot.com/
> > > > --
> > > > -
> > > > To unsubscribe from this list: send the line
> > > > "unsubscribe linux-kernel" in
> > > > the body of a message to
> > majordomo@vger.kernel.org
> > > > More majordomo info at
> > > > http://vger.kernel.org/majordomo-info.html
> > > > Please read the FAQ at 
> http://www.tux.org/lkml/
> > > >
> > > 
> > > 
> > > Manomugdha Biswas
> > > 
> > > 
> > > 
> > >
> >
>
__________________________________________________________
> > > Yahoo! India Matrimony: Find your partner now.
> Go
> > to http://yahoo.shaadi.com
> > > 
> > 
> > 
> > -- 
> > - Gaurav
> > my blog: http://lkdp.blogspot.com/
> > --
> > 
> 
> 
> Manomugdha Biswas
> 
> 
> 		
>
__________________________________________________________
> 
> Yahoo! India Matrimony: Find your partner now. Go to
> http://yahoo.shaadi.com
> 


Manomugdha Biswas


		
__________________________________________________________ 
Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com

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

* Re: wait_event_interruptible_timeout problem
       [not found] <4MjuE-6Cb-37@gated-at.bofh.it>
@ 2005-09-13 23:30 ` Robert Hancock
  2005-09-14  6:31   ` Gaurav Dhiman
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Hancock @ 2005-09-13 23:30 UTC (permalink / raw)
  To: linux-kernel

manomugdha biswas wrote:
>  Hi,
>  I have a kernel module (kernel 2.6) where I have
>  opened multiple tcp connections. when there is no
>  data
>  i want my process to sleep. For that i have added
>  the
>  following code.
>   
>  /* Initialise the wait q head */
>    init_waitqueue_head(&VNICClientWQHead);
>  
>  init_waitqueue_entry(&(currentMap->waitQ), current);
>  add_wait_queue(currentMap->sock->sk->sk_sleep,
>  &(currentMap->waitQ));
>  
>  /* here currentMap is a structure containing tcp
>  conenction info for my module. There is a currentMap
>  for each tcp connection */
>  
>  wait_event_interruptible_timeout(VNICClientWQHead,
>                                   0, HZ * 100000);
>  
>  I am not sure about the condition argument, 0. 

The condition should be an expression that returns true when whatever 
you are waiting for occurs - in this case when data is available. If you 
put the condition as 0 it will never wake up.

Also, why the huge timeout? If you just want to sleep forever, use 
regular wait_event_interruptible.

-- 
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/



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

* Re: wait_event_interruptible_timeout problem
  2005-09-13 13:51 manomugdha biswas
@ 2005-09-14  6:14 ` manomugdha biswas
  0 siblings, 0 replies; 4+ messages in thread
From: manomugdha biswas @ 2005-09-14  6:14 UTC (permalink / raw)
  To: manomugdha biswas, linux-kernel; +Cc: gaurav4lkg

Hi,

  wait_event_interruptible_timeout(VNICClientWQHead,
                                   <condition>, HZ *
100000);

I want to use this function to sleep my process when
there is no activity. But when some data arrives on
socket this function should wake up. I have declared a
wait queue as VNICClientWQHead. So what will be the
condtion here to wake up the process when data is
available on sockets? I have multiple sockets.

Regards,
Mano


  Regards,
  Mano
>  
> > 
> > 
> > 
> > 
> > --- Gaurav Dhiman <gaurav4lkg@gmail.com> wrote:
> > 
> > > On 9/13/05, manomugdha biswas
> > > <manomugdhab@yahoo.co.in> wrote:
> > > > Hi,
> > > > I am using the this function in the following
> > way:
> > > 
> > > you are using it wrong way ....
> > > 
> > > > 
> > > > wait_queue_head_t     VNICClientWQHead;
> > > > 
> > > > /* Initialise the wait q head */
> > > > init_waitqueue_head(&VNICClientWQHead);
> > > > 
> > > > init_waitqueue_entry(&waitQ, current);
> > > > add_wait_queue(sock->sk->sk_sleep, waitQ));
> > > 
> > > need not to do this at all, as all this is done
> by
> > > wait_event_interruptible_timepout() function.
> Just
> > > here you initialize
> > > the head of the list.
> > > 
> > > > 
> > > > /*
> > > >  my code, it reads data from socket
> > > > */
> > > > 
> > > >
> > wait_event_interruptible_timeout(VNICClientWQHead,
> > > 0,
> > > > HZ * 100000);
> > > > 
> > > > if no activity is to be done then this process
> > > sleeps.
> > > > When some data comes in socket i.e socket
> > becomes
> > > > readable this process should wake up. In
> kernel
> > > 2.4 it
> > > > was working fine using
> > > interruptible_sleep_on_time().
> > > > But it is not working in kernel 2.6 even if
> data
> > > > arrives in socket! The sleeping process never
> > wake
> > > up.
> > > > Could you please tell me what is the problem?
> > > > 
> > > > Regards,
> > > > Mano
> > > > 
> > > > 
> > > > --- Gaurav Dhiman <gaurav4lkg@gmail.com>
> wrote:
> > > > 
> > > > > On 9/13/05, manomugdha biswas
> > > > > <manomugdhab@yahoo.co.in> wrote:
> > > > > > Hi,
> > > > > > I was using
> interruptible_sleep_on_timeout()
> > > in
> > > > > kernel
> > > > > > 2.4. In kernel 2.6 I have use
> > > > > > wait_event_interruptible_timeout. But it
> is
> > > now
> > > > > > working!!.
> interruptible_sleep_on_timeout()
> > > was
> > > > > > working fine. Could anyone please help me
> in
> > > this
> > > > > > regard.
> > > > >
> > > > > What problem are you facing with
> > > > > wait_event_interruptible_timeout() in 2.6
> > > > > Elaborate more on it.
> > > > >
> > > > > -Gaurav
> > > > >
> > > > > > Regards,
> > > > > > Mano
> > > > > >
> > > > > > Manomugdha Biswas
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
__________________________________________________________
> > > > > > Yahoo! India Matrimony: Find your partner
> > now.
> > > Go
> > > > > to http://yahoo.shaadi.com
> > > > > > -
> > > > > > To unsubscribe from this list: send the
> line
> > > > > "unsubscribe linux-kernel" in
> > > > > > the body of a message to
> > > majordomo@vger.kernel.org
> > > > > > More majordomo info at
> > > > > http://vger.kernel.org/majordomo-info.html
> > > > > > Please read the FAQ at 
> > > http://www.tux.org/lkml/
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > - Gaurav
> > > > > my blog: http://lkdp.blogspot.com/
> > > > > --
> > > > > -
> > > > > To unsubscribe from this list: send the line
> > > > > "unsubscribe linux-kernel" in
> > > > > the body of a message to
> > > majordomo@vger.kernel.org
> > > > > More majordomo info at
> > > > > http://vger.kernel.org/majordomo-info.html
> > > > > Please read the FAQ at 
> > http://www.tux.org/lkml/
> > > > >
> > > > 
> > > > 
> > > > Manomugdha Biswas
> > > > 
> > > > 
> > > > 
> > > >
> > >
> >
>
__________________________________________________________
> > > > Yahoo! India Matrimony: Find your partner now.
> > Go
> > > to http://yahoo.shaadi.com
> > > > 
> > > 
> > > 
> > > -- 
> > > - Gaurav
> > > my blog: http://lkdp.blogspot.com/
> > > --
> > > 
> > 
> > 
> > Manomugdha Biswas
> > 
> > 
> > 		
> >
>
__________________________________________________________
> > 
> > Yahoo! India Matrimony: Find your partner now. Go
> to
> 
=== message truncated ===


Manomugdha Biswas


		
__________________________________________________________ 
Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com

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

* Re: wait_event_interruptible_timeout problem
  2005-09-13 23:30 ` wait_event_interruptible_timeout problem Robert Hancock
@ 2005-09-14  6:31   ` Gaurav Dhiman
  0 siblings, 0 replies; 4+ messages in thread
From: Gaurav Dhiman @ 2005-09-14  6:31 UTC (permalink / raw)
  To: Robert Hancock; +Cc: linux-kernel

On 9/14/05, Robert Hancock <hancockr@shaw.ca> wrote:
> manomugdha biswas wrote:
> >  Hi,
> >  I have a kernel module (kernel 2.6) where I have
> >  opened multiple tcp connections. when there is no
> >  data
> >  i want my process to sleep. For that i have added
> >  the
> >  following code.
> >
> >  /* Initialise the wait q head */
> >    init_waitqueue_head(&VNICClientWQHead);
> >
> >  init_waitqueue_entry(&(currentMap->waitQ), current);
> >  add_wait_queue(currentMap->sock->sk->sk_sleep,
> >  &(currentMap->waitQ));
> >
> >  /* here currentMap is a structure containing tcp
> >  conenction info for my module. There is a currentMap
> >  for each tcp connection */
> >
> >  wait_event_interruptible_timeout(VNICClientWQHead,
> >                                   0, HZ * 100000);
> >
> >  I am not sure about the condition argument, 0.
> 
> The condition should be an expression that returns true when whatever
> you are waiting for occurs - in this case when data is available. If you
> put the condition as 0 it will never wake up.

On timeout it will wake up, even if the condition is 0 ..... bu in
this case the time out is too big. Try with small timeout value and
you will see that your process wakes up.

-Gaurav

> 
> Also, why the huge timeout? If you just want to sleep forever, use
> regular wait_event_interruptible.
> 
> --
> Robert Hancock      Saskatoon, SK, Canada
> To email, remove "nospam" from hancockr@nospamshaw.ca
> Home Page: http://www.roberthancock.com/
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


-- 
- Gaurav
my blog: http://lkdp.blogspot.com/
--

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

end of thread, other threads:[~2005-09-14  6:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4MjuE-6Cb-37@gated-at.bofh.it>
2005-09-13 23:30 ` wait_event_interruptible_timeout problem Robert Hancock
2005-09-14  6:31   ` Gaurav Dhiman
2005-09-13 13:51 manomugdha biswas
2005-09-14  6:14 ` manomugdha biswas

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