如何通知用户空间应用程序驱动程序已在Linux中收到中断? [英] How do I inform a user space application that the driver has received an interrupt in linux?

查看:509
本文介绍了如何通知用户空间应用程序驱动程序已在Linux中收到中断?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PCIe设备,当准备读取数据缓冲区时,它将发送硬件中断.我相信最好的方法是使用信号,但是我不确定如何使用信号.我相信我需要做的是:

I have a PCIe device that will send a hardware interrupt when a data buffer is ready to be read. I believe the best approach for this is to use signals but I'm not entirely sure how. What I believe I need to do is:

  1. 保存用户空间应用程序的PID,以便驱动程序知道将信号发送到哪里
  2. 在PCIe设备驱动程序的中断处理程序中,向用户空间应用程序发送信号
  3. 在用户空间应用程序中实现信号处理程序功能以处理信号

我不确定如何执行这两个操作. 如何/在哪里保存用户空间应用程序的PID? 如何从驱动程序的中断处理程序向该特定的PID发送信号(我相信我应该使用kill命令,但我对获取PID的语法更感兴趣)? 用户空间应用程序如何在保存其PID后等待信号? 是否可以使用户空间应用程序在保存其PID之后继续运行,在收到信号时运行信号处理程序功能,并继续在信号到达之前的位置继续运行? (类似于情监侦的工作原理)

I'm not sure how to do either of these. How/Where do I save the PID of the user space application? How do I send a signal to that specific PID from the driver's interrupt handler (I believe I should use the kill command but I'm more interested in the syntax of getting the PID)? How do I have the user space application wait for the signal after saving its PID? Is it possible to have the user space application continue to run after saving its PID, run the signal handler function when a signal is received, and continue running where it was before the signal arrived? (similar to how an ISR works)

推荐答案

请勿为此使用信号.实现字符设备.用户空间应用程序将open它,然后调用read并将被阻止,直到您的驱动程序确定有可用数据为止.

Don't use signals for this. Implement a character device. The userspace application will open it, then call read and will be blocked until your driver determines there is data available.

我认为,请参阅 Linux设备驱动程序.

这篇关于如何通知用户空间应用程序驱动程序已在Linux中收到中断?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆