Linux设备驱动之阻塞I/O与异步通知(2)

使用方法:

static int xxx_fasync(int fd, struct file *filp, int mode) { struct xxx_dev *dev = filp->private_data; return fasync_helper(fd, filp, mode, &dev->async_queue); } static ssize_t xxx_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) { struct xxx_dev *dev = filp->private_data; ... /* 产生异步读信号 */ if (dev->async_queue) kill_fasync(&dev->async_queue, SIGIO, POLL_IN); /* POLL_OUT可写 */ ... } static int xxx_release(struct inode *inode, struct file *filp) { /* 将文件从异步通知列表中删除 */ xxx_fasync(-1, filp, 0); ... return 0; }

本文永久更新链接地址

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/9c7ea4dea08550baa26658c7f8274c7c.html