This is actually one of the challenges I'm facing right now with channels (IPC) 
in Fusion.

Since it's a single address space OS, a design goal I'm aiming for is to create 
a "shared heap" between the sender and the receiver processes, allowing for 
sharing pointers across process boundaries.

  * This shared heap would be mapped writable by the sender and readable by the 
receiver.
  * The sender would allocate objects directly on that heap, instead of its own 
heap.
  * The sender would invoke a syscall to send the message, which points to data 
on the shared heap.
  * The receiver invokes a blocking syscall to receive a message, and gets a 
pointer to the data on the shared heap.



This would achieve zero-copy IPC. However, AFAIK Nim doesn't support multiple 
heaps (at least not with ARC/ORC). I wish there was an ability to create 
[MemRegion](https://github.com/nim-lang/Nim/blob/cb7bcae7f73bb907170f67e5e245f474a48760b3/lib/system/alloc.nim#L149)s
 with an associated OS allocator instance, so that allocating against a 
specific `MemRegion` would use separately managed heap pages.

So what I'm likely to do is deepcopy objects from the sener's heap to the 
channel shared heap. Unfortunately Nim's built-in deepcopy allocates on the 
process heap, so I have to write my own custom deepcopy that allocates on the 
shared heap. Oh well.

Reply via email to