Linux内核如何中断应用程序? [英] How does Linux kernel interrupt the application?

查看:101
本文介绍了Linux内核如何中断应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我是一名设备驱动程序专家.这是我第一次处理用户模式程序.我曾经有一个中断服务程序来响应硬件中断.换句话说,硬件使用中断服务程序来通知驱动程序进行服务.我现在将ioctl用作在应用程序和设备驱动程序之间进行通信的渠道,并对其进行轮询以等待响应.设备驱动程序还有其他方法可以在完成某些任务时通知应用程序吗?欢迎任何意见.谢谢,

First of all, I am a device driver guy. This is my first time to handle an user mode program. I used to have an interrupt service routine to response a hardware interrupt. In other word, the hardware uses interrupt service routine to notify the driver to service. I use ioctl to be a channel to communicate between the application and device driver now and poll it to wait the response. Are there other ways that a device driver can notify an application when it finishes some task? Any comments are welcome. Thanks,

推荐答案

有几种机制.第一种方法:用户空间应用程序使 poll() Netlink套接字.还有其他类似 mmap()或信号.Google通过内核用户空间IPC ,您将看到整个列表.

There are several mechanisms for this. First approach: user-space application makes poll() or select() system call, waiting for some event from kernel. Second approach is to use Netlink sockets. There are also others like mmap() or signals. Google by kernel user-space IPC and you will see the whole list.

对于您的情况(驱动程序开发),我想说下一种方法.在驱动程序中创建sysfs文件,然后 sysfs_notify()(也许还有 wait_for_completion_interruptible_timeout()之类的东西).在用户空间中,对驱动程序sysfs文件进行 select()系统调用.查看如何从用户空间安装行规程例如.

As for your case (drivers development), I'd say go with next approach. Create sysfs file in your driver, and do sysfs_notify() (and maybe wait_for_completion_interruptible_timeout() or something like that). In user-space do select() system call for your driver sysfs file. See how line discipline installed from user-space for example.

这篇关于Linux内核如何中断应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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