简体   繁体   English

如何代理mmap在网络上进行读写?

[英]How can I proxy mmap reads and writes across a network?

I'm working on software to control a mmap'd device on an embedded ARM system, but have run into a few situations where the debugging and development tools available haven't been sufficient. 我正在开发用于控制嵌入式ARM系统上的mmap'd设备的软件,但是遇到了一些可用的调试和开发工具不足的情况。 ie Instrumentation tools like valgrind and higher end thread profilers are unavailable. 即,无法使用诸如valgrind和更高端的线程分析器之类的工具。

What I'd like to do is compile my code on an x86 machine, mmap a 'dummy' segment of memory using the same size and then proxy those reads/writes across the network to the embedded machine which could then respond accordingly. 我想做的是在x86机器上编译我的代码,使用相同的大小映射内存的“虚拟”段,然后将那些通过网络的读/写代理到嵌入式计算机,然后嵌入式计算机可以相应地做出响应。

I realize this would likely require a client/server mechanism and would be excruciatingly slow but the benefits of having this option would make the mechanics outside of the mmap interface itself (async event handling, thread management) available to instrument using x86 development tools would be very useful. 我意识到这很可能需要客户机/服务器机制,并且运行速度非常慢,但是使用此选项的好处将使mmap接口本身之外的机制(异步事件处理,线程管理)可供使用x86开发工具的仪器使用。很有用。

I've heard of this technique in some ASIC development for simulation but never used anything that provided this functionality. 我在一些用于仿真的ASIC开发中听说过该技术,但从未使用过任何提供此功能的东西。 The key point here is that I want to use the same code on both platforms without having to rewrite a bunch of stuff, or have to write a kernel module that has any hardware handling logic in it. 这里的关键点是,我想在两个平台上使用相同的代码,而不必重写大量内容,也不必编写包含任何硬件处理逻辑的内核模块。 I want to keep all the device control logic in userland through mmap 我想通过mmap将所有设备控制逻辑保留在用户区中

If you think this through, basically this boils down to implement a remote file system. 如果您仔细考虑一下,基本上可以归结为实现远程文件系统。

  • the "easiest" would probably if your embedded device could realize a simple version of the NFS client side, and mmap a file on your desktop machine 如果嵌入式设备可以实现NFS客户端的简单版本并在台式机上mmap文件,则“最简单”
  • the inverse should also be possible, namely to have nfs server modules running on you embedded system and to export something like /dev/shm as an nfs mount point to your desktop. 反之也应该是可能的,即在嵌入式系统上运行nfs服务器模块,并将/dev/shm作为nfs挂载点导出到桌面。

For both approaches (any any other using mmap ) you must be really careful on data synchronization. 对于这两种方法(任何其他使用mmap ),您都必须非常小心数据同步。 But as long as you have a typical debug setting with basically one writer and one reader this could be doable. 但是,只要您具有典型的调试设置,并且基本上只有一位编写者和一位读者即可,那么这是可行的。 If this gets more complicated, there is remote file locking available as an nfs extension. 如果这变得更加复杂,则可以将远程文件锁定作为nfs扩展名使用。

I have wanted something similar in the past but never really got around to implementing it. 我过去曾经想要类似的东西,但从未真正实现它。 However you might want to give something like memcached a look, I know its normally used for web/db based stuff, but it might be possible to abuse it for this purpose, especially since it is for debug. 但是,您可能想给一些像memcached的外观,我知道它通常用于基于Web / db的东西,但是为此目的可能会滥用它,尤其是因为它是用于调试的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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