How kernel notify a user space program an interrupt occurrs

前端 未结 1 1200
别跟我提以往
别跟我提以往 2021-01-18 02:48

I\'m writing a user space program and a kernel space device driver.

Goal: Once an interrupt occurs, user space program needs to do something quickly.

My naiv

相关标签:
1条回答
  • 2021-01-18 03:15

    There is a similar question asked here:

    Notify gpio interrupt to user space from a kernel module

    Please check above question. However, i can provide my approach which i suggested there as well.

    You can send a signal to user space thread from kernel API, which can help u run non-blocking:

    send_sig(int sig, struct task_struct *p, int priv);
    

    You need to be aware of pid of user thread in Kernel. You can over come this by writing pid of user process via /proc and then kernel reading the pid. With this arrangement, when there is an interrupt, kernel can send signal to user thread. In case your process restarts or gets killed, you will have to update the pid via proc. Just for status notification you can use this method; however if you like to transfer data along with status than Netlink or char driver mechanism is good way.

    0 讨论(0)
提交回复
热议问题