???????????豸?????е?poll()????????????????£?
????static unsigned int poll(struct file *file?? struct socket *sock??poll_table *wait)
????//???????????file????????????????????????????????????y?????????
??????????????豸??????仯???????е???poll_wait()????????????????????????poll_table
?????????????????豸??????????????д?????????
???????????poll_wait()??????????????????wait_event()?????????????????????????????????????????????????????????????????????????????????wait????????????б?poll_table?????poll_wait()??????????£?
????static inline void poll_wait(struct file * filp?? wait_queue_head_t * wait_address?? poll_table *p)
???????п?????????????????wait_address????p???????????(poll_table)
?????????????е?poll()??????????????£?
static unsigned int xxx_poll(struct file *filp??struct socket *sock??
poll_table *wait)
{
unsigned int mask = 0;
struct xxx_dev *dev = filp->private_data;
//????豸???????
...
poll_wait(filp??&dev->r_wait??wait);
//?????????????poll_table
poll_wait(filp??&dev->w_wait??wait);
//??д??????????poll_table
...
if(...)
//???
mask |= POLLIN | POLLRDNORM;
if(...)
//??д
mask |= POLLOUT | POLLRDNORM;
...
return mask;
}
????????????????????globalfifo????
??????globalfifo??poll()?????У???????豸???????r_wait??w_wait?????????????????б??globalfifo?豸??????poll()???????£?
static unsigned int gloablfif0_poll(struct file *filp??poll_table *wait)
{
unsigned int mask = 0;
struct globalfifo_dev *dev = filp->private_data;
down(&dev->sem);
poll_wait(filp??&dev->r_wait ?? wait) ;
poll_wait(filp??&dev->r_wait ?? wait) ;
if(dev->current_len != 0)
{
mask |= POLLIN | POLLRDNORM;
}
if(dev->current_len != GLOBALFIFO_SIZE)
{
mask |= POLLOUT | POLLWRNORM;
}
up(&dev->sem);
return mask;
}
??????????
?????????????????????
???????岢???????????????
???????岢???????????У?
????????????????????????
???????y???????TASK_INTERRUPTIBLE???????????????TASK_UNINTERRUPTIBLE???????????????
????????????????
????poll?????
????????????????poll_table
?????????????????豸??????????????д?????????