1

Does Android support process-shared mutexes and condition variables? I've heard bionic implementation doesn't support them because Android has other means of IPC, but cannot find information that would either confirm or deny it.

The sources are a bit confusing. In bionic's pthread_mutex.cpp just before pthread_mutexattr_setpshared there is a comment:

    /* process-shared mutexes are not supported at the moment */

But inside the function there is also written:

         /* our current implementation of pthread actually supports shared
         * mutexes but won't cleanup if a process dies with the mutex held.
         * Nevertheless, it's better than nothing. Shared mutexes are used
         * by surfaceflinger and audioflinger.
         */

So has anybody used process-shared mutexes (and cond vars) in native android applications (by sharing them with ashmem_create_region, for example)?

olegst
  • 1,209
  • 1
  • 13
  • 33

2 Answers2

1

1, Android does support the shared mutex. 2, Android does not support robust mutex(robust futex) which can "cleanup if a process dies with the mutex held".

So, only the system process can use it (never crash or killed, if it crash, the system reboot).

alpha
  • 1,228
  • 1
  • 11
  • 26
0

I've managed to get it working on Android 5.0, so they are supported. One of the processes creates shared memory and shares file descriptor with the other one, both mmap it and it works.

olegst
  • 1,209
  • 1
  • 13
  • 33