Question about multi threads visiting shared arena
刘希晨
benrush0705 at gmail.com
Mon Mar 27 07:48:37 UTC 2023
I have a question about using MemorySegment with Arena.openShared().
I don't know if the memory created by Arena.openShared() or any other
shared scope would be safely accessed by multiple threads.
Simply put, if a writer thread wrote something into the MemorySegment and
then passing it to the reader thread using a BlockingQueue,
I am confused if the writer operation would already be visible to the
reader thread.
I have tested its visibility using jcstress and it turns out every
Varhandle.get() will successfully read the data changed in another thread,
even without volatile or locks, so I am confused if the jvm has already
created memory fence for memorysegment's access.
I hope the authorities could offer a suggested way of accessing same memory
segment in multiple threads in Panama FFI's documentation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20230327/9aa16961/attachment.htm>
More information about the panama-dev
mailing list