I am trying to create shared memory that will be used by several processes. these processes interact with each other using MPI calls ( MPI_Send , MPI_Recv ).
I need a mechanism to control access to this shared memory. Yesterday I added a question to find out if MPI supports any tool for this. A shared memory access control mechanism for processes created by MPI , but MPI does not seem to exist.
So I need to choose between named semaphore or flock .
For the named semaphore, if any of the processes suddenly dies without calling sem_cloe() , this semaphore always remains and ll /dev/shm/ can be noticed. This sometimes leads to a deadlock (if I run the same code again!), For this reason I am now thinking about using the pack.
Just wanted to confirm whether flock is suitable for this type of operation?
Are there any disadvantages to using flock ?
Is there anything else besides named semaphore and flock that can be used here?
I am working on C under linux.
nav_jan
source share