[squeak-dev] Backing a Form with e.g. mmap() or shm
Tony Garnock-Jones
tonyg at leastfixedpoint.com
Thu Jun 23 18:16:12 UTC 2022
On 6/23/22 19:41, Eliot Miranda wrote:
> So in this use including the header in the first page would be ok?
Yes, this would be fine. Ideally the beginning of the data portion would
be page-aligned but I suspect the server may not actually care, and
anything 8- or 16-byte aligned would probably be just fine.
> Would the mapping be read-only from the perspective of the X server?
It could be, yes, but ideally it'd be possible to have it read-write so
that I could grab pixels from the server as well as send them.
The address of the mapping may have to be fixed for the lifetime of the
relationship with the server - I don't know why, but the address is
included in the wire protocol, not just the segment identifier. I need
to dig deeper.
> Do
> you need shmget to be run via the FFI or would it be OK to invoke it
> implicitly as part of a mapping allocation primitive?
It'd be OK if it were done primitively but I do need access to the shm
ID etc.
mmap incidentally can work as well but I need to implement fd passing
which is fiddly and involves sendmsg. I'm putting it off if I can :-)
> Would it be
> better to create the mapping via the FFI and provide the mapping to
> the allocation primitive?
It might be better if the primitives could cope with chunks of external
memory from arbitrary sources - then I could manage shm and/or mmap
myself via the FFI.
> How should the mapping be taken down?
By manual invocation of some kind of free()-analogue, I suspect; so from
the GC's point of view, the object holding the external bytevector is
permanent until explicitly, manually released. And I think it's probably
best if the image-side is responsible for deallocating the chunk of
memory too (obvs if it is supplied in a mechanism-agnostic way to the GC
this holds double!)
> Windows folks, how portable is this idea to other OS's,
> especially windows? (I'm guessing this is a standard facility on most
> leading OS's). So would it be worth evolving towards a cross-platform
> abstraction?
If you get to hand chunks-o-RAM to the GC without having to talk about
how you got them, it might be pretty portable automatically.
> Procedural:
> Would you be prepared to build the VM to test this? Perhaps even
> generate it from sources? To what extent would you be able to
> collaborate with e.g. Tom & myself in implementing this?
Yes, I would be happy building. I would also be happy generating from
sources, though I might have silly questions about the process for the
first couple of hours. I'd be happy to collaborate.
Cheers,
Tony
More information about the Squeak-dev
mailing list
|