Shared memory path to custom path

Hi all, Is it possible to change the shared memory segment path from /dev/shm to other directory ex. /tmp/shm_file instead of /dev/shm/shm_file. Regards, Murali Kishore

El 23/10/2024 a las 14:53, Murali Kishore via Boost escribió:
Hi all,
Is it possible to change the shared memory segment path from /dev/shm to other directory ex. /tmp/shm_file instead of /dev/shm/shm_file.
Regards, Murali Kishore
Pure shared memory needs an special filesystem in POSIX systems, so no. You can use mapped files to create shared memory that is backed by a file in an arbitrary directory. Best, Ion

Hi Ion, I have tried one experiment, copying shared memory from one linux server to another linux server; both are identical w.r.t os and memory configuration. I am able to open shared memory and access stored classes in another server. want to check with you on this, is there any issues or this procedure is ok to use or any expected abnormal behaviours later. Please help to understand how this works if both servers are identical. -- Regards, Murali Kishore

El 08/11/2024 a las 5:19, Murali Kishore via Boost escribió:
Hi Ion,
I have tried one experiment, copying shared memory from one linux server to another linux server; both are identical w.r.t os and memory configuration. I am able to open shared memory and access stored classes in another server.
want to check with you on this, is there any issues or this procedure is ok to use or any expected abnormal behaviours later. Please help to understand how this works if both servers are identical.
If the ABI is identical (same compiler, with same options, with same OS...) then it should work. Best, Ion

On Fri, Nov 8, 2024, at 5:19 AM, Murali Kishore via Boost wrote:
Hi Ion,
I have tried one experiment, copying shared memory from one linux server to another linux server; both are identical w.r.t os and memory configuration. I am able to open shared memory and access stored classes in another server.
want to check with you on this, is there any issues or this procedure is ok to use or any expected abnormal behaviours later. Please help to understand how this works if both servers are identical.
There's no logical distinction between creating a shared memory segment in one process, ending the process and reopening the same segment in a new process and what you describe. I'd personally replace `managed_shared_memory` with `managed_mapped_file` so the intent of treating the mapped segment as a file becomes more clear. In effect, shared memory on linux is just a file in a special kind of filesystem, anyways. Also, you're responsible for keeping track of consistency during copy (e.g. if you copy the data during a mutation, you may incur undefined behavior on use (incl. opening), and/or you may encounter a stuck lock). Seth
participants (3)
-
Ion Gaztañaga
-
Murali Kishore
-
Seth