在LDD3,我看到这样的代码为什么我们需要在poll中调用poll_wait?
static unsigned int scull_p_poll(struct file *filp, poll_table *wait)
{
struct scull_pipe *dev = filp->private_data;
unsigned int mask = 0;
/*
* The buffer is circular; it is considered full
* if "wp" is right behind "rp" and empty if the
* two are equal.
*/
down(&dev->sem);
poll_wait(filp, &dev->inq, wait);
poll_wait(filp, &dev->outq, wait);
if (dev->rp != dev->wp)
mask |= POLLIN | POLLRDNORM; /* readable */
if (spacefree(dev))
mask |= POLLOUT | POLLWRNORM; /* writable */
up(&dev->sem);
return mask;
}
但它说poll_wait不会等待,将立即返回。那为什么我们需要打电话呢?为什么我们不能只返回面具?
然后做的过程中睡眠时? – demonguy
@demonguy查看我的更新回答 –
您的意思是说,来自用户空间的查询调用会阻止进程,对不对? – demonguy