2002-02-28 22:32:00

by Marek Zawadzki

[permalink] [raw]
Subject: simple 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