简体   繁体   中英

how to access the kernel memory from user program in rt linux?

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.

//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
}

// 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. ie my program .

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 ??

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

You can:

  • Export timestamp through sysfs or debugfs and read it as regular file
  • Add syscall so kernel will return current timestamp value
  • Bunch of other crazy variants like netlink socket or shared memory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM