[lkml]   [2002]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjectsimple problem with sleeping/waking up

I want to implement the 2 following functions in 2.4.17 kernel:

fun1(struct sock *sk)
while (some_pointer == NULL) {
/* do nothing */

fun2(struct sock *sk)
/* some event occured -- data vailable */
some_pointer == something;

I am doing it in networking stack (not a module) to implement accept(fun1)
function. fun2 is supposed to be my main receiving function, which should
wake accept up after receiving some data.
So far I tried this:
accept(struct sock sk*)
DECLARE_WAITQUEUE(wait, current);
current->state = TASK_INTERRUPTIBLE;
while (1) {
schedule_timeout(timeo); /* process sleeps after that */
if (some_pointer != NULL) {
current->state = TASK_RUNNING;
remove_wait_queue(sk->sleep, &wait);

receive(struct sock sk*)
/* after getting the data */A
some_pointer = sk;
wake_up_interruptible(sk->sleep); /* this hangs my machine :-(*/

Please help, it'll be so greatly appreciated, since I've spent almost a
week trying to do that...

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:21    [W:0.028 / U:1.616 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site