Oleh Derevenko(deleted)
08/04/2009 11:43 AM
post35184
|
I'm trying to implement a mutex in shared memory but have run into a problem.
My system is QNX 6.3.0 SP3.
A single process creates a file with shm_open( , O_RDWR | O_CREAT, ) under /dev/shmem and maps it as mmap(, PROT_READ |
PROT_WRITE, MAP_SHARED, ).
Then process initializes a mutex in shared section with PTHREAD_PROCESS_SHARED and sets a boolean in shared section to
indicate the mutex is initialized.
Then process locks the mutex and terminates on assertion failure afterwards.
When I start the process for the second time the file already exists so the process only opens it with shm_open(, O_RDWR
, ) without ftruncate() and maps into memory.
It detects the flag that the mutex is already created so it does not do anything else to init the mutex.
After that pthread_mutex_trylock() returns EINVAL instead of expected EBUSY and SyncMutexRevive() returns EINVAL too.
Is that the expected behavior? I was sure the mutex should persist even after all the clients terminate until the file
is unlinked. Otherwise there is not much sense in all those dances around SyncMutexRevive().
|
|
|