All the implementations were compiled and tested on Linux (Ubuntu 20.4).
Run make
inside the subfolders to build for the target system. POSIX calls on Linux requires -lrt
to run, so Makefile includes -lrt
when building on Linux.
posix_ipc is available on PyPI:
pip install posix-ipc
Or you can clone the project and install it using setup.py:
git clone https://github.com/osvenskan/posix_ipc.git
cd posix_ipc
python setup.py install
posix_ipc is compatible with all supported versions of Python 3. For complete documentation of posix_ipc module, see https://github.com/osvenskan/posix_ipc.git.
Run shared memory writer
./shm_writer.exe $MSG_SIZE
Run shared memory reader
./shm_reader.exe
Run shared memory writer
./shm_writer.exe $MSG_SIZE
Run shared memory reader (I separate the shared memory cleaner in System-V implementation)
./shm_reader.exe && ./shm_clean.exe
Run shared memory writer
python3 shm_writer.py $MSG_SIZE
Run shared memory reader
python3 shm_reader.py
-
Writer creates a shared memory object (shm_open in POSIX, ftok + shmget in System-V)
-
Writer attaches to the shared memory object (mmap in POSIX, shmat in System-V)
-
Writer writes contents to the shared memory object
-
Writer sends the pointer to the Reader (e.g., using UNIX socket, SKMSG, RTE RING)
-
Reader attaches to shared memory object (Note: this step can be done during the startup)
-
Reader reads the shared memory object
Based on the messaging flow, we can breakdown the shared memory communication latency into the following pieces:
- Shared memory object creation latency;
- Shared memory object attaching latency;
- Shared memory object write latency;
- Pointer transmission latency;
There are other latencies, which are not derived from shared memory communication, but may amortize the benefit of shared memory communication:
- Serialization/Desrialization latency to support structured data/binary data conversion