simple problem with sleeping/waking up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux