如何访问用户程序的内核内存在RT Linux呢? [英] how to access the kernel memory from user program in rt linux?

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

问题描述

客户端,并在室温Linux服务器通信。客户端发送的数据和服务器是receiver.UDP用于客户端和服务器之间的通信。
当服务器(RT Linux)的从客户端接收数据的内核应该停止它在做什么,并开始执行新接收数据。我希望在中断内核(时间戳)发生时计算时间。
在RT-Linux的所有操作系统的操作发生在内核中。所以我计算内核源码code中断时间。所以我修改了位置/usr/src/linux-version/net/core/dev.c内核源码code,如下图所示:
我计算的时间和在缓冲器SKB存储

client and server communication in rt linux. client is sending the data and server is the receiver.UDP is used for communication between client and the server. When the server(rt linux) receives the data from the client the kernel should stop what it is doing and start executing the newly arrived data. I want to calculate the time when the interrupt occurs in kernel (timestamp). In rt-linux all the operating system operation takes place in kernel. So i am calculating the interrupt time in kernel source code. So i modified the kernel source code in the location /usr/src/linux-version/net/core/dev.c as shown below : I am calculating the time and storing in a buffer skb.

//这个code是在网络设备驱动程序级别。

//this code is at network device driver level.

int netif_rx(struct sk_buff *skb) 
{
    __net_timestamp(skb);//I modify the code in kernel to get the timestamp and store in buffer
}

//数据存储到缓冲器后。内核将其发送给像IP,UDP,INET终于内核空间的SOCKET上层。

// after storing the data to the buffer. kernel will send it to the upper layers like IP, UDP, INET and finally SOCKET of the kernel space.

,但欲由用户空间读取从内核空间中的时间戳数据包。即我的程序。

but I want to read the timestamp packet from the kernel space by the user space. i.e. my program .

我使用recvfrom的API来读取内核spacce(这是在内核内存)

I am using recvfrom api to read the data from kernel spacce (which is in kernel memory)

问:有人能告诉我如何访问内核内存,用户程序??

QUESTION : could someone tell me how to access the kernel memory which contains the timestamp data by the user program ??

推荐答案

您无法从用户空间访问内核的内存直接 - 你必须使用某种形式的API。

You can't access kernel memory from userspace directly - you have to use some sort of API.

您可以:


  • 通过sysfs的或debugfs出口时间戳,并把它读作常规文件

  • 添加系统调用所以内核返回当前时间戳值

  • 喜欢的网络连接套接字或共享内存等变种疯狂这帮

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

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