Re: "Move memory" in no time



Johannes Singler wrote:

Jan Panteltje wrote:

For API compatibility, I need to move a large block of data to another
place in memory. I really need to only _move_ it, I don't need the
original data any more. So far I call memcpy and free up the original
space afterwards. Now I was wondering if there is a kernel call that
achieves this by just changing some page table entries. In this case, no
transfer would be necessary and the move should be much faster.

Is this possible? Can we maybe abuse some mmap-related calls for that?

I do not get it, say you have allocated that space with malloc, now you
have a pointer to it.
When you want to 'move' it means something else should get in the place
of the space used by that pointer.
Then leave that space and let the 'something else' use a different space?

But 'something else' assumes that the input data has been transformed
in-place, i. e. the output has to reside at that specific location in
memory. This is a fixed API postcondition which I cannot change.
Any ideas anyway?

Bye,
Johannes

I think I understand what you are looking for. The API you are using states
it needs something at a particular memory location. This location is fixed
within the API and cannot be changed?

If this is the case, I would suggest writing a driver. This way the driver
will live in kernel space. Then you app would communicate with the driver
via some entry in /dev.

As far as I know, a user-space app cannot make abitrary decisions about the
physical (or virtual) memory locations. Only the kernel can do that.
However, perhaps someone better suited can correct me if I'm wrong.

Alvin
.



Relevant Pages

  • Network device driver Question
    ... I'm working on a driver for a new device. ... It can DMA to/from any memory location. ... The problem I have is with a CPU that has a writeback cache. ...
    (Linux-Kernel)
  • Re: call by address vs. call by value
    ... Why is a bolt better than a nail? ... Call by value means that the contents of a piece of memory is passed ... Could be an integer, a floating point number, a whole 10 kb string. ... need to work on the original data, or on/with a copy of it. ...
    (comp.lang.c)
  • Re: "Move memory" in no time
    ... place in memory. ... original data any more. ... So far I call memcpy and free up the original ... the space used by that pointer. ...
    (comp.os.linux.development.apps)
  • RE: Accessing memory filled by a DMA process
    ... memory location you are interested in. ... my video driver fills a part of memory with teletext data. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: "Move memory" in no time
    ... For API compatibility, I need to move a large block of data to another ... place in memory. ... original data any more. ... the space used by that pointer. ...
    (comp.os.linux.development.apps)