🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.mach
Article #1102

Efficient copying from task to task

#1102
From: Roland Karlsson
Date: Fri, 17 May 1991 07:45
66 lines
3010 bytes
I have two tasks with the same virtual memory layout.  Now I want to
(very efficiently) copy a block from one task to another task.  The
block shall be at the same addresses in both tasks.  The block do not
have to start or end at page boundaries.  The block can consist of any
number of integers.  It can be just some bytes or several megabytes.
This copying is made very frequently during execution of several one
thread tasks (=processes).

Proposal one:
------------
The solution in UNIX was to map the memory, to a file, with mmap.  All
UNIX processes can then map other processes memory to another address.
Then can an ordinary block copy be used.

    File:
    -------------
    | 0 | 1 | 2 |
    -------------

    Map for process 0:   Map for process 1:   Map for process 2:
    -------------        -------------        -------------
    | 0 | 1 | 2 |        | 1 | 2 | 0 |        | 2 | 0 | 1 |
    -------------        -------------        -------------
    x                    x                    x

I have tried to use vm_map to implement this behavior, but in without
success.  Every time I use vm_map (with the memory_object
MEMORY_OBJECT_NULL) to the same offset in the memory object it looks
like I get a new piece of memory, not an alias for the same.  Can it
be done???  Someone said the magical word "external pager" but I do
not know how to use it.


Proposal two:
------------
You could ignore the above mapping method and use a combination of
vm_write (for integral pages) and copying via a buffer (for parts of
pages).  This should be straight forward I think.  But I do not want
to copy via a buffer (this means copying two times) and I would also
like to use vm_read (this means also copying two times) as the task
that wants the memory otherwise would be idle during copying (when
they could copy half the memory each).


Refinement one to proposal two:
-------------------------------
It would be very nice if I could use a "copy on write" technique to
copy the integral pages from one task to another task.  How can that
be made???

Refinement two to proposal two:
-------------------------------
Can I write/read parts of pages to/from another tasks memory without
mapping???  Then I do not have to copy twice for small blocks.


Proposal three:
--------------
Something completely different.  But what???


--
Roland Karlsson
SICS, PO Box 1263, S-164 28 KISTA, SWEDEN	Internet: roland@sics.se
Tel: +46 8 752 15 40	Ttx: 812 61 54 SICS S	Fax: +46 8 751 72 30
Technical Details
Message-ID: <1991May17.074526.19128@sics.se>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!sics.se!sics.se!roland

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!sics.se!sics.se!roland
From: roland@sics.se (Roland Karlsson)
Newsgroups: comp.os.mach
Subject: Efficient copying from task to task
Message-ID: <1991May17.074526.19128@sics.se>
Date: 17 May 91 07:45:26 GMT
Sender: news@sics.se
Distribution: comp
Organization: Swedish Institute of Computer Science, Kista
Lines: 66