Suppose I've a process P1, which generates itself a lot of data , for
example 2Mb.
Then, I've a process P2 which must access P1 shared memory and,
probably, modify this data.
To accomplish this, I've been digging around python's mmap module, but I
can't figure how to use it without files.
Could anybody explain me how could this be accomplished? An example will
be very appreciated. Thanks a lot for your help. 5 6036
Carl Banks wrote:
In C you can use the mmap call to request a specific physical location
in memory (whence I presume two different processes can mmap anonymous
memory block in the same location)
Um, no, it lets you specify the *virtual* address in the process's
address space at which the object you specify is to be mapped.
As far as I know, the only way two unrelated processes can share
memory via mmap is by mapping a file. An anonymous block is known
only to the process that creates it -- being anonymous, there's
no way for another process to refer to it.
However, if one process is forked from the other, the parent
can mmap an anonymous block and the child will inherit that
mapping.
(I suppose if both processes had sufficient privileges they
could map physical memory out of /dev/mem, but that would be
*really* dangerous!)
--
Greg
greg wrote:
Carl Banks wrote:
>In C you can use the mmap call to request a specific physical location in memory (whence I presume two different processes can mmap anonymous memory block in the same location)
Um, no, it lets you specify the *virtual* address in the process's
address space at which the object you specify is to be mapped.
As far as I know, the only way two unrelated processes can share
memory via mmap is by mapping a file. An anonymous block is known
only to the process that creates it -- being anonymous, there's
no way for another process to refer to it.
On POSIX systems, you can create a shared memory object without a file
using shm_open. The function returns a file descriptor.
However, if one process is forked from the other, the parent
can mmap an anonymous block and the child will inherit that
mapping.
(I suppose if both processes had sufficient privileges they
could map physical memory out of /dev/mem, but that would be
*really* dangerous!)
--
Greg
In article <Ko******************************@comcast.com>,
Jeff Schwab <je**@schwabcenter.comwrote:
greg wrote:
Carl Banks wrote:
In C you can use the mmap call to request a specific physical location
in memory (whence I presume two different processes can mmap anonymous
memory block in the same location)
Um, no, it lets you specify the *virtual* address in the process's
address space at which the object you specify is to be mapped.
As far as I know, the only way two unrelated processes can share
memory via mmap is by mapping a file. An anonymous block is known
only to the process that creates it -- being anonymous, there's
no way for another process to refer to it.
On POSIX systems, you can create a shared memory object without a file
using shm_open. The function returns a file descriptor.
Sorry I missed the OP, but you might be interested in this shared memory
module for Python: http://NikitaTheSpider.com/python/shm/
--
Philip http://NikitaTheSpider.com/
Whole-site HTML validation, link checking and more
Nikita the Spider wrote:
In article <Ko******************************@comcast.com>,
Jeff Schwab <je**@schwabcenter.comwrote:
>greg wrote:
>>Carl Banks wrote: In C you can use the mmap call to request a specific physical location in memory (whence I presume two different processes can mmap anonymous memory block in the same location) Um, no, it lets you specify the *virtual* address in the process's address space at which the object you specify is to be mapped.
As far as I know, the only way two unrelated processes can share memory via mmap is by mapping a file. An anonymous block is known only to the process that creates it -- being anonymous, there's no way for another process to refer to it.
On POSIX systems, you can create a shared memory object without a file using shm_open. The function returns a file descriptor.
Sorry I missed the OP, but you might be interested in this shared memory
module for Python: http://NikitaTheSpider.com/python/shm/
Thanks; I just downloaded it. It seems to be missing the INSTALL file;
any idea where I could find that, or should I write to the author?
In article <C5******************************@comcast.com>,
Jeff Schwab <je**@schwabcenter.comwrote:
Nikita the Spider wrote:
In article <Ko******************************@comcast.com>,
Jeff Schwab <je**@schwabcenter.comwrote:
greg wrote: Carl Banks wrote: In C you can use the mmap call to request a specific physical location in memory (whence I presume two different processes can mmap anonymous memory block in the same location) Um, no, it lets you specify the *virtual* address in the process's address space at which the object you specify is to be mapped.
As far as I know, the only way two unrelated processes can share memory via mmap is by mapping a file. An anonymous block is known only to the process that creates it -- being anonymous, there's no way for another process to refer to it.
On POSIX systems, you can create a shared memory object without a file
using shm_open. The function returns a file descriptor.
Sorry I missed the OP, but you might be interested in this shared memory
module for Python: http://NikitaTheSpider.com/python/shm/
Thanks; I just downloaded it. It seems to be missing the INSTALL file;
any idea where I could find that, or should I write to the author?
The main author has been AWOL for some years now. I'm the current
maintainer. Sorry about the missing INSTALL file. Looks like I made
reference to it in the README but never created it. It installs with the
normal setup.py:
sudo python setup.py
I'll put out an updated package with an INSTALL file one of these days.
Thanks for pointing that out.
Cheers
--
Philip http://NikitaTheSpider.com/
Whole-site HTML validation, link checking and more This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sr |
last post by:
I have this kind of a code.
It is from a book Linux programming,
unleashed.
I am not able to make to work so that, when it is run in two different
xterm windows, the two different processes would...
|
by: myeates |
last post by:
Hi
Anyone ever done this? It looks like Python2.4 won't take a length arg
Mathew
|
by: George Sakkis |
last post by:
I've been trying to track down a memory leak (which I initially
attributed erroneously to numpy) and it turns out to be caused by a
memory mapped file. It seems that mmap caches without limit the...
|
by: James T. Dennis |
last post by:
I've been thinking about the Python mmap module quite a bit
during the last couple of days. Sadly most of it has just been
thinking ... and reading pages from Google searches ... and
very little...
|
by: Seisouhen |
last post by:
Hi all,
I am using mmap to obtain some space(mapped anonymously) and am giving the address of the assigned space to a struct pointer. Then I want to access a member of the struct that the pointer...
|
by: JKPeck |
last post by:
According to the mmap.mmap 2.5 documentation,
"Changed in version 2.5: To map anonymous memory, -1 should be passed
as the fileno along with the length."
I would like to use shared memory to...
|
by: Akira Kitada |
last post by:
Hi list,
I was trying to build Python 2.6 on FreeBSD 4.11 and found it failed
to build some of the modules.
"""
Failed to find the necessary bits to build these modules:
_bsddb ...
|
by: Akira Kitada |
last post by:
Hi Marc-Andre,
Thanks for the suggestion.
I opened a ticket for this issue: http://bugs.python.org/issue4204
Now I understand the state of the multiprocessing module,
but it's too bad to see...
|
by: M.-A. Lemburg |
last post by:
On 2008-10-25 20:19, Akira Kitada wrote:
Thanks.
The errors you are getting appear to be related to either some
missing header files or a missing symbol definition to enable
these - looking...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |