Dear All:

When I use wak_up_interruptible(), I found some strange problems. The
details is as follows:

Firstly, I write a char device driver:

static ssize_t
my_read(struct file *file, char __user *buf, ssize_t len, loff_t *off)
{
...
wait_event_interruptible(my_wait_queue, 0);
...
}

....

int
my_char_init(void)
{
return register_chrdev(MY_CHAR_MAJOR, "/dev/mychar", &mychar_ops);
}

....

then, I make node in directory:
#mknod "/dev/mychar" c MY_CHAR_MAJOR 0

It is time to write an app to check it:

int
main(void)
{
...

read(fd, my_buf, MY_LEN)
...

return 0;
}

when running this check code, the process waits someone to wake up it.

So I write a module to give it a stimulus:

int
stimulus_init(void)
{
wake_up_interruptible(&my_wait_queue);
}
....

The check steps are:
1. insmod my_char_module
2. running check application
the process waits
3. insmod stimulus_module

It is very strange that the check application has no reaction at all.
It just waits there.
So I modify the stimulus module as follows:

int
stimulus_init(void)
{
...
LINE 1: printk_state_of_process_in_wait_queue; /* the process pid is
the same to the application */
LINE 2: wake_up_interruptible(&my_wait_queue);
LINE 3: printk_state_of_process_in_wait_queue and check the
wait_queue empty;

return 0;
}

void
stimulus_exit(void)
{
LINE 4: check_the wait_queue is empty or not;

return ;
}

the result is:
LINE 1: the process state: TASK_INTERRUPTIBLE (1)
LINE 3: the process state: TASK_RUNNING (0), wait_queue is empty

LINE 4: the wait_queue is NOT empty

Why the wait_queue not empty at LINE 4?

Since at LINE 2 the process moves to running queue and it is indeed
done from the result at LINE 3, why at LINE 4 is it in the wait_queue?

anybody has a suggestion? thanks in advance

Michael