Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
linux网络驱动程序功能中的永久睡眠?_Linux_Kernel_Linux Device Driver - Fatal编程技术网

linux网络驱动程序功能中的永久睡眠?

linux网络驱动程序功能中的永久睡眠?,linux,kernel,linux-device-driver,Linux,Kernel,Linux Device Driver,在linux网络驱动程序中: ssize_t device_read(struct file *file,char *buffer,size_t length, loff_t *offset) { #ifdef _DEBUG int i; #endif struct ed_device *edp; DECLARE_WAITQUEUE(wait,current); edp = (struct ed_device *)file->private_data; add_wait_queue(&am

在linux网络驱动程序中:

ssize_t device_read(struct file *file,char *buffer,size_t length, loff_t *offset)
{
#ifdef _DEBUG
int i;
#endif
struct ed_device *edp;
DECLARE_WAITQUEUE(wait,current);
edp = (struct ed_device *)file->private_data;
add_wait_queue(&edp->rwait,&wait);
for(;;){

    set_current_state(TASK_INTERRUPTIBLE);
    if ( file->f_flags & O_NONBLOCK)
        break;
    if ( edp->tx_len > 0)
        break;

    if ( signal_pending(current))
        break;
printk("Start going to sleep\n");
    schedule();
printk("return from scheduler\n");
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&edp->rwait,&wait);

spin_lock(&edp->lock);

if(edp->tx_len == 0) {
     spin_unlock(&edp->lock);
     return 0;

}else
{...}
}
在一个简单的应用程序中调用函数
read(fd\u tx,tx\u ptr,BUFFER\u SIZE-1)
后,内核进程
device\u read
进入休眠状态,并打印信息
Start to sleep
。它永远不会被唤醒,除非应用程序停止,然后打印从调度程序返回的信息

为什么进程不能被其他函数中的
唤醒可中断(&ed[ed\u TX\u DEVICE].rwait)
唤醒