access to preallocated block of memory?

sam samschul at pacbell.net
Thu Dec 15 22:07:00 CET 2005


I had a simular situation when I was writing Python routines to access
the the storage (SCSIPASSTHROUGH) layer provided by Windows XP. My
solution was to develope an extention in C that allocated all storage
buffers within the extension. Then I added access extensions to
controll reading and writing to and from these buffers. I would guess
that you can write a vxworks extension that provides this linkage.
Bengt Richter wrote:
> On 14 Dec 2005 14:30:34 -0800, "Greg Copeland" <gtcopeland at gmail.com> wrote:
>
> >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!
>
> What have you gathered from people who have gone before? googling python vxworks
> gives about 50k hits ;-)
>
> Your post does not have enough info about your environment, but for
> the sake of eliciting same, suppose you had a custom extension module
> written in C that would give you the access to the "reserved area of memory"
> that you want. So e.g. from the point of view of your python program, it looks
> like a module you can import, e.g.,
>
>     import vxreservedmem
>
> Ok, how does the module know where the "reserved area" is? Would you link
> the C to some vx library interface to establish location and size? Or?
> Is there already a python interface to provide some access?
> Can there be more than one instance, so the module should be able to
> give you multiple objects that you can use to access different areas?
>
> Once you have an access-providing object, what kind of access do you require?
> What is represented within the "memory area" besides an array of bytes? Do the
> bytes represent C structs and primitive types? Are there access locks that
> determine when it's safe to touch the bytes? A single lock for the whole area,
> or individual locks for structs/subregions within the whole? Do you just need
> read access or do you want to store info? How would you like to select
> chunks of info? Just slices of byte arrays, or are there meaningful arrays
> of numbers -- integer, floats, etc. or bit fields etc?
>
> You could define a pure python vxresrvedmem module that just simulates the real
> thing, to test ideas -- and to communicate more clearly to us what the problem is.
>
> What modules/libraries do you have to give you access now from python to the vxworks
> environment? A file system? /dev/magic_stuff? or /proc/magic_stuff or ?
> 
> 
> Regards,
> Bengt Richter




More information about the Python-list mailing list