Workqueue的应用
来源:互联网 发布:java并发 编辑:程序博客网 时间:2024/06/05 14:57
工作队列允许内核代码请求某个函数在未来的时间被调用,具有很好的灵活性,其运行在特殊的内核线程,该线程没有对应的用户空间可以访问,因此,工作队列函数不能访问用户空间,但是可以休眠。
TP的私有数据结构:
TP的私有数据结构:
struct msg21xx_ts_data { int irq; struct work_struct work; struct i2c_client *client; struct workqueue_struct *msg21xx_wq;};probe函数中与工作队列有关的部分摘录如下:
static int msg21xx_ts_probe(struct i2c_client *client, const struct i2c_device_id *id){ struct msg21xx_ts_data *data; data = kzalloc(sizeof(struct msg21xx_ts_data), GFP_KERNEL); data->msg21xx_wq = create_singlethread_workqueue("msg21xx_wq"); INIT_WORK(&data->work, msg21xx_ts_work_func); request_threaded_irq(client->irq, NULL, msg21xx_irq_handler, IRQF_TRIGGER_RISING | IRQF_ONESHOT, client->dev.driver->name, data);}
当TP发生中断时,msg21xx_irq_handler函数被调用,改函数会调用queue_work像工作队列提交任务:
static irqreturn_t msg21xx_irq_handler(int irq, void *dev_id){struct msg21xx_ts_data *data = (struct msg21xx_ts_data *)dev_id;disable_irq_nosync(data->irq);queue_work(data->msg21xx_wq, &data->work);return IRQ_HANDLED;}执行queue_work(data->msg21xx_wq, &data->work);后,msg21xx_ts_work_func函数会被调用,该函数完成触摸数据的读取和上报。
0 0
- Workqueue的应用
- linux tasklet和workqueue的应用情景
- linux tasklet和workqueue的应用情景
- linux tasklet和workqueue的应用情景
- linux tasklet和workqueue的应用情景
- WorkQueue在Android马达驱动上的应用
- tasklet与workqueue的区别和不同应用环境总结 .
- Workqueue机制的实现
- Workqueue机制的实现
- workqueue的变化
- workqueue
- workqueue
- workqueue
- workqueue
- workqueue .
- workqueue
- workqueue
- workqueue
- 简单的邮件开发3---Java
- iOS 数组中元素的替换
- 第二章 算法分析
- AsyncTask介绍
- JAVA全角字符转换为半角字符
- Workqueue的应用
- leetcode 125 Valid Palindrome C++
- 对Photoshop高斯模糊滤镜的算法总结
- Android jni开发资料--NDK环境搭建
- 文件操作以及实现文件的复制操作并且在目的目录创建相应文件夹
- canvas.drawText文字居中(备忘)
- Visual Studio 2013的Browser Link功能的使用,忽略js异常
- Linux下Mysql5.6版本安装日志
- 《剑指offer》变态跳台阶