Shared Memory Requested Size

dchiu
2022-04-06
2024-07-04
  • dchiu - 2022-04-06

    I have encountered an issue trying to establish stable communication between CODESYS and a C++ process under CODESYS Linux SL.

    I followed the shared memory example provided on CODESYS store and was able to read/write into a shared memory created by an external C++ process.

    However when I tried to scale the application up with multiple named shared memory, problem occurs with some of the shared memory size.
    Multiple shared memory were created using POSIX shm_open()in C++, and has no problem when reading and writing by multiple processes without CODESYS. However as soon as CODESYS is started, CODESYS SysSharedMemoryOpen2() will cause unexpected behavior for a certain shared memory size.

    For example, if I have 2 shared memory reads, shm1 and shm2. shm1 would behave perfectly, but shm2 will display ulSize=0 (declared to be size 48 in the program) as soon as the PLC goes into RUN state.
    When I checked in /dev/shm for the problematic shared memory size, the shared memory size seems to be normal(48 as allocated). pResult of the CODESYS SysSharedMemoryOpen2() yields no error as well(ERR_OK 16#00)

    This problem only occurs occasionally in Linux SL 4.2.0, I could allocate a larger memory size than necessary(100)and the application would work sometimes.

    I tried to remedy this by updating the PLC to 4.4.1. Now the problem occurs every single time and cannot be worked around by adjusting with pulSize parameter.

    Has anyone encountered something similar?
    Is there any suggestion on solving this problem?

    Thank you for your time
    Derek

     
  • viktorr - 2024-07-04

    Hello Derek,
    I recognize this is an older post, but i was wondering if found any ways to remedy this. I am running into what i think is the same problem you had here.

    Thank you in advance for any information,
    Viktor

     
  • viktorr - 2024-07-04
     

    Last edit: viktorr 2024-07-04

Log in to post a comment.