In LDD3, ho visto tali codiciPerché dobbiamo chiamare poll_wait nel sondaggio?
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;
}
Ma dice poll_wait non aspettiamo e tornerà immediatamente. Allora perché dobbiamo chiamarlo? Perché non possiamo semplicemente restituire la maschera?
Poi, quando fa il sonno processo? – demonguy
@demonguy Vedi la mia risposta aggiornata –
Vuoi dire che la chiamata di polling dallo spazio utente bloccherà il processo, giusto? – demonguy