在Linux中的中断上下文中运行用户线程 [英] Running user thread in context of an interrupt in linux

查看:151
本文介绍了在Linux中的中断上下文中运行用户线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些自定义的应用程序,并允许在Linux内核修改中断处理程序代码.

I am writing some customized application and allowed to change interrupt handler code in the linux kernel.

我具有被等待中断发生一个用户线程.如果发生该中断,那么我要做的第一件事就是执行该用户线程.

I am having a user thread which is waiting for an interrupt to happen. If that interrupt happens then the first thing I want to do is to execute that user thread.

有什么办法可以使它工作.

Is there any way to make it work.

谢谢

推荐答案

创建一个字符设备(内核所做的就是处理设备).有从该设备读取用户线程.由于没有字符可读取,因此它将挂起.

Create a character device (that's what the kernel does, handles devices). Have the user thread read from that device. It will hang as there are no characters to read.

当中断发生时,从您的模块向该设备输出一个字符(或一些有意义的消息).该线程将唤醒,阅读消息并继续.

When the interrupt happens, output a character (or some meaningful message) to that device from your module. The thread will wake up, read the message and continue.

给处理程序线程一些优先级,以便它可以早起.

Give the handler thread some nice priority so that it wakes up early.

或者,您可能只是让线程在selectsleep上等待,并向其发送信号(内核函数kill_proc_info),该线程将被唤醒.确保线程处理信号.

Alternatively, you may just have the thread waiting on select or sleep and send it a signal (kernel function kill_proc_info) and the thread will wake up. Make sure the thread handles the signal.

这篇关于在Linux中的中断上下文中运行用户线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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