Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Is it possible to get the Physical memory address of a variablein python?

Reply
Thread Tools

Re: Is it possible to get the Physical memory address of a variablein python?

 
 
Ognjen Bezanov
Guest
Posts: n/a
 
      11-10-2009
Hey,

Thanks for all the responses guys. In hindsight I probably should have
explained why on earth I'd need the physical address from an interpreted
language.

I'm trying to see if there is any way I can make Python share data
between two hosts using DMA transfers over a firewire connection, so
avoiding the need for another layer on top such as IPv4 + Python sockets.

Thanks to some old python bindings which I updated to python 2.6, I can
read any write to the RAM of any firewire connected host within python.
Because it uses DMA (the cpu is not involved in this at all), I can only
specify a physical address within the 4GB ram limit to read from and
write to.

Now what I've done so far is on the remote host I run python and set a
variable as so:

a = "foo"
print a
'foo'

Then on the local host I run a python script that scans the entire RAM
looking for the string "foo", and replaces it with the string "oof". I
have had success with this method. Once it's done and I do "print a" on
the remote host, I get "oof" as the variable value, so in theory it can
work.

Problem is that it's slow. Scanning 3GB of RAM every time you want to do
this is not a good method. I thought that if I could get python to
return the physical address of where the value of a variable is, then I
can just jump to that address and write the data.

From what I've been told so far, it's not possible to do this without
some OS-specific (Linux in this case) syscall. Is this correct?

Thanks!


Ognjen

 
Reply With Quote
 
 
 
 
Carl Banks
Guest
Posts: n/a
 
      11-10-2009
On Nov 10, 3:32*am, Ognjen Bezanov <(E-Mail Removed)> wrote:
> Hey,
>
> Thanks for all the responses guys. In hindsight I probably should have
> explained why on earth I'd need the physical address from an interpreted
> language.
>
> I'm trying to see if there is any way I can make Python share data
> between two hosts using DMA transfers over a firewire connection, so
> avoiding the need for another layer on top such as IPv4 + Python sockets.
>
> Thanks to some old python bindings which I updated to python 2.6, I can
> read any write to the RAM of any firewire connected host within python.
> Because it uses DMA (the cpu is not involved in this at all), I can only
> specify a physical address within the 4GB ram limit to read from and
> write to.


[snip]

> *From what I've been told so far, it's not possible to do this without
> some OS-specific (Linux in this case) syscall. Is this correct?



What you'd normally need to do it to use system calls to allocate a
DMA-able memory buffer, then copy contents of your Python object
(which you get at using buffer protocol) to this buffer, then initiate
the DMA transfer. At this point it probably would be easier to just
write a C-extension to do that, but I see no reason it can't be done
with ctypes.

However, I'm not sure how that would interact with your pre-existing
module. I'd expect a module that does DMA to take care of physical
address mapping itself, you just pass it a logical address, or an
object that supports buffer protocol, and it does the rest.

It seems just getting a physical address and starting a DMA transfer
from it is prone to danger if memory pages are discontiguous (and they
often are), but maybe OSes these days can handle that automatically.


Carl Banks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
total memory available is only 3.3GB with 4GB physical memory under windows 7 64 bit someone@somewhere.com Windows 64bit 19 01-12-2010 10:33 AM
Is it possible to get the Physical memory address of a variable inpython? Ognjen Bezanov Python 1 11-10-2009 02:30 AM
MAC Address/Physical Address? SJ ASP .Net 0 01-07-2006 12:59 AM
virtual address or physical address? sushant C Programming 9 02-18-2005 10:48 PM
convert virtual address to physical address Krishna Sagiraju C Programming 3 07-10-2004 08:41 PM



Advertisments