👍Really interesting, thanks for _sharing_ (pun intended)
@itf_ph3r0x41
Жыл бұрын
Cool stuff, didn't know you could create shared mem like this... Is this managed by memory mapped files, or how exactly does it work? I managed to create a shared memory for two of my dll's and created a basic two sided communication class, and wanted to accomplish safe comms by using a spinlock using a std::atomic bool. I had problems with this spinlock though: As I was using shared memory, I couldn't instantiate the spinlock in the shared memory... So I tried to interpret a part of that memory as the spinlock structure, but the methods didn't seem to work properly. I am wondering, why this is the case though... The atomicness of the bool should be implemented by atomic assembly instructions, and functions are both located in the .text section... You have any idea how to use custom locks in shared mem? In the end I had to rely on windows and use a windows mutex object, which kinda did the trick, but I want to use less kernel objects if possible...
@zodiacon
Жыл бұрын
It is a memory mapped file, because EXEs and DLLs are mapped with these - it's just a matter of providing the right attributes. std::atomic should work fine generally, but one process has no idea of the other, so initialization would occur once per-process.
@tkothadev
Жыл бұрын
do you know if there is an equivalent method for doing this on mac os or unix? Having this available cross-platform would be extremely handy
@zodiacon
Жыл бұрын
I don't know. I think your best bet for cross-platform code for sharing memory is the BOOST libraries.
@oleh6738
Жыл бұрын
If there are two executable images with sections with the same name, that have the Shared attribute set, do prcesses of those images share the memory section, or do those processes must come from the same image?
@zodiacon
Жыл бұрын
Must be the same executable.
@oleh6738
Жыл бұрын
@@zodiacon Thank you! Very interesting video. Didn’t know that yet.
@mustafadurukan6893
Жыл бұрын
Then what is the difference between IPC and shared memory, they both provides us to use communicate processes right?
@zodiacon
Жыл бұрын
IPC is a generic term for inter-process communication, which could use many mechanisms. For example: window messages, sockets, named pipes, mailslots... and more. Shared memory happens to be one such mechanism.
@mustafadurukan6893
Жыл бұрын
Excellent explanation thanks Pavel can you make a video about IPCs you talked about. I'm eager to learn them. Thanks again
@zodiacon
Жыл бұрын
Sure, I'll add some of these mechanisms to my list of future videos
Пікірлер: 13