https://en.wikipedia.org/wiki/Netlink

https://stackoverflow.com/questions/12899055/how-kernel-notify-a-user-space-program-an-interrupt-occurrs

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.

https://stackoverflow.com/questions/19257624/interrupt-handling-and-user-space-notification

You don't need fancy kernel to userspace communication. A userspace application has access to GPIOs using Sysfs. Read about it in Documentation/gpio.txt.

First, export a GPIO pin like this (the actual number depends on your setup):

# echo 23 > /sys/class/gpio/export

This will export GPIO pin #23, and thus create /sys/class/gpio/gpio23.

Set its direction:

# echo in > /sys/class/gpio/gpio23/direction

If the hardware GPIO controller supports interrupts generation, the driver should also support it and you will see /sys/class/gpio/gpio23/edge. Write either risingfalling or both to this file to indicate the signal edge(s) that will create a "userspace interrupt". Now, to get interrupted, use the poll(2) system call on /sys/class/gpio/gpio23/value. Then, when the poll call unblocks, read the new value (/sys/class/gpio/gpio23/value), which will be '0' or '1' (ASCII).

ASK:

The main my question is: How to send notification with information from interrupt handler to user space application. I am using not only gpio interrupts. So in userspace I need to determine which interrupt occurred. If it possible, please present some examples how it can be done. Thanks... 
ANSWER:
In that case, you could do the same thing that GPIO does with poll(2) on a custom Sysfs entry for your driver. Otherwise, check out Netlink.

Netlink: 内核与用户空间传输数据的socket协议的更多相关文章

  1. Linux启动时间优化-内核和用户空间启动优化实践

    关键词:initcall.bootgraph.py.bootchartd.pybootchart等. 启动时间的优化,分为两大部分,分别是内核部分和用户空间两大部分. 从内核timestamp 0.0 ...

  2. linux内存(三)内核与用户空间交互

    来自网址http://www.kerneltravel.net/jiaoliu/005.htm 用户程序和内核的信息交换是双向的,也就是说既可以主动从用户空间向内核空间发送信息,也可以从内核空间向用户 ...

  3. Linux内核访问用户空间文件:get_fs()/set_fs()的使用

    测试环境:Ubuntu 14.04+Kernel 4.4.0-31 关键词:KERNEL_DS.USER_DS.get_fs().set_fs().addr_limit.access_ok. 参考代码 ...

  4. 用户空间和内核空间通讯之【Netlink 上】

    原文地址:用户空间和内核空间通讯之[Netlink 上] 作者:wjlkoorey258 引言 Alan Cox在内核1.3版本的开发阶段最先引入了Netlink,刚开始时Netlink是以字符驱动接 ...

  5. linux 内核与用户空间通信之netlink使用方法

    转自:http://blog.csdn.net/haomcu/article/details/7371835 Linux中的进程间通信机制源自于Unix平台上的进程通信机制.Unix的两大分支AT&a ...

  6. linux 内核与用户空间通信机制netlink初探

      1.Linux进程概述 Linux中的进程间通信机制源自于Unix平台上的进程通信机制.Unix的两大分支AT&T Unix和BSD Unix在进程通信实现机制上各有所不同,前者形成了运行 ...

  7. 深入理解linux网络技术内幕读书笔记(三)--用户空间与内核的接口

    Table of Contents 1 概论 1.1 procfs (/proc 文件系统) 1.1.1 编程接口 1.2 sysctl (/proc/sys目录) 1.2.1 编程接口 1.3 sy ...

  8. 深入理解Linux网络技术内幕——用户空间与内核空间交互

    概述:     内核空间与用户空间经常需要进行交互.举个例子:当用户空间使用一些配置命令如ifconfig或route时,内核处理程序就要响应这些处理请求.     用户空间与内核有多种交互方式,最常 ...

  9. linux 用户态和内核态以及进程上下文、中断上下文 内核空间用户空间理解

    1.特权级         Intel x86架构的cpu一共有0-4四个特权级,0级最高,3级最低,ARM架构也有不同的特权级,硬件上在执行每条指令时都会对指令所具有的特权级做相应的检查.硬件已经提 ...

随机推荐

  1. Celery-系统守护进程

    1. 使用systemd控制Celery 用法: systemctl {start|stop|restart|status} celery.service 配置文件: /etc/celery/cele ...

  2. WeQuant教程—1.2 从简单的量化系统开始

    你大概知道量化的思想最早在古巴比伦人计算行星轨迹的时候就已经诞生(算术运算),后来借助古希腊的形式化逻辑的发展,人们日益能从量化的思想中提炼和描述自然规律并运用到生产之中.不过,基于量化的思想打造一个 ...

  3. Quartz学习笔记:集群部署&高可用

    Quartz学习笔记:集群部署&高可用 集群部署 一个Quartz集群中的每个节点是一个独立的Quartz应用,它又管理着其他的节点.这就意味着你必须对每个节点分别启动或停止.Quartz集群 ...

  4. Ubuntu16.0.4安装OpenCV3.4.2

    (1)到官网下载opencv3.4.2,链接:https://opencv.org/releases.html (2)下载opencv_contrib,链接:https://github.com/op ...

  5. 【windows】win10局域网共享文件夹

    1.打开 2.共享文件夹 另一台局域网电脑可根据共享的电脑ip访问就可以了[格式:\\ip] 如果右键文件夹没有共享选项

  6. IDEA的java源码文件左边有一个红色的J

    解决办法: 如果源码文件这里已经有一个路径,那就添加现在的.java文件所在目录,或者删除了再重新添加

  7. Java reactor响应式编程

    转载自:https://www.cnblogs.com/lixinjie/p/a-reactive-streams-on-jvm-is-reactor.html 响应式编程 作为响应式编程方向上的第一 ...

  8. [Docker] Windows 宿主环境下,共享或上传文件到容器的方法

    需求如题. 解决方案1 - 挂载目录(适用于创建新的容器) 格式-v 容器目录 或 -v 本地目录:容器目录 范例Linux宿主环境下:使用镜像 nginx:latest,以后台模式启动一个容器,将容 ...

  9. sqlserver 数据类型 C# clr 数据类型 映射

    https://docs.microsoft.com/zh-cn/dotnet/framework/data/adonet/sql/linq/sql-clr-type-mapping#default- ...

  10. 【LEETCODE】71、验证二叉树的前序序列化

    简单粗暴,代码有待优化,不过自己独立完成,没有参考任何材料,还是比较满意的 package y2019.Algorithm.stack.medium; import java.util.Stack; ...