lkml.org 
[lkml]   [2001]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectwait_event() problems <patch>

I have been trying to get the following to work:

atomic_t stop;
struct wait_queue wait_queue_stuff, another_wait_queue;
/* Initialized before use with init_wait_queue() */

kernel_thread()
{
for(;;)
{
if(atomic_read(stop))
interruptible_sleep_on(&wait_queue_stuff);
do_regular_stuff();
}
}

ioctl_start()
{
if(waitqueue_active(&wait_queue_stuff))
{
atomic_set(&stop, 0);
wake_up_interruptible(&wait_queue_stuff);
}
}
ioctl_stop()
{
if(!waitqueue_active(&wait_queue_stuff))
{
atomic_set(&stop, 1);
wait_event(another_wait_queue, waitqueue_active(&wait_queue_stuff));
}
}

The problem is that when ioctl_stop() is executed, the kernel thread
never gets any CPU time so it remains stuck in "D" state forever.

Maybe I'm doing something wrong, but something seems to be broken.
The following patch 'fixes' it.



--- linux-2.4.1/include/linux/sched.h.orig Tue Jul 3 15:14:07 2001
+++ linux-2.4.1/include/linux/sched.h Tue Jul 3 15:16:27 2001
@@ -763,6 +763,7 @@
set_current_state(TASK_UNINTERRUPTIBLE); \
if (condition) \
break; \
+ current->policy = SCHED_YIELD; \
schedule(); \
} \
current->state = TASK_RUNNING; \

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

I was going to compile a list of innovations that could be
attributed to Microsoft. Once I realized that Ctrl-Alt-Del
was handled in the BIOS, I found that there aren't any.


-
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 12:56    [W:0.027 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site