访问预分配的内存块? [英] access to preallocated block of memory?

查看:61
本文介绍了访问预分配的内存块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VxWorks上运行python。在操作过程中,vxworks

任务写入保留的内存区域。我需要从python中访问这个块

的内存。最初我以为我可以简单地将
作为一个字符串访问它,但是一个字符串会重新分配并复制这个块

的内存;这不是我可以拥有的东西,因为它会浪费大量的内存。我们在设备上谈论类似40MB的东西

,内存有限。我一直在看阵列。看起来很有希望。

这里最好的路线是什么?理想情况下,我想简单地在保留块的地址和长度中传递

,并且可以访问内存




我可以使用一些现有的python对象/工具,还是需要

来创建自定义模块?任何提示,提示或指示肯定会赞赏


谢谢,


Greg

I am running python on VxWorks. In the course of operation, a vxworks
tasks writes to a reserved area of memory. I need access to this chunk
of memory from within python. Initially I thought I could simply
access it as a string but a string would reallocate and copy this chunk
of memory; which is not something I can have as it would waste a huge
amount of memory. We''re talking about something like 40MB on a device
with limited RAM. I have been looking at array. It looks promising.
What''s the best route to go here? Ideally, I would like to simply pass
in the address of the reserved block and a length, and have the memory
accessible.

Is there some existing python object/facility I can use or will I need
to create a custom module? Any tips, hints, or pointers would
certainly be appreciated!
Thanks,

Greg

推荐答案

>>> vxworks任务写入保留的内存区域。


是否与mmap模块兼容?

>>> vxworks tasks writes to a reserved area of memory.

Is it compatible with the mmap module ?


On 2005-12-15,Do Re Mi chel La Si Do< en ************** @ Omcla​​veauO.com>写道:
On 2005-12-15, Do Re Mi chel La Si Do <en**************@OmclaveauO.com> wrote:
vxworks tasks写入保留的内存区域。
vxworks tasks writes to a reserved area of memory.




Is it compatible with the mmap module ?




我从来没有写过VxWorks模块,但它只需要一个

编写一个Linux驱动程序的十二行代码,以便将预定义的地址空间块
映射到用户空间中。


-

格兰特爱德华兹格兰特哇!佑!我在窗口砸了



visi.com



I''ve never written a VxWorks module, but it would only take a
dozen or two lines of code to write a Linux driver that would
impliment mmap() to allow a pre-defined block of address space
to be mapped into user space.

--
Grant Edwards grante Yow! Yow! I threw up on
at my window!
visi.com


所以数组无法映射前现有大块的记忆?我没有在mmap模块中移植

,因为VxWorks上不存在这样的语义。基于

到目前为止的评论,看起来mmap是我最好的选择吗?任何

其他选项?

So array can not map a pre-existing chunk of memory? I did not port
the mmap module because such semantics don''t exist on VxWorks. Based
on comments thus far, it looks like mmap is my best bet here? Any
other options?


这篇关于访问预分配的内存块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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