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

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

fun1(struct sock *sk)
{
GO_TO_SLEEP_SOMEHOW(sk->sleep???);
while (some_pointer == NULL) {
/* do nothing */
}
}

fun2(struct sock *sk)
{
/* some event occured -- data vailable */
some_pointer == something;
WAKE_SLEEPING_PROCESS(sk->sleep)
}

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) {
break;
}
}
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...
-marek

-
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/

\
 
 \ /
  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