On 20.05.2016 11:15, Joerg Sonnenberger wrote: > On Thu, May 19, 2016 at 01:36:29PM -0400, Christos Zoulas wrote: >> You can see how FreeBSD is implementing them; it is a lot of code to do >> this and would require some architectural review. The relevant files are: >> >> http://nxr.netbsd.org/xref/src-freebsd/lib/libthr/thread/thr_pshared.c >> http://nxr.netbsd.org/xref/src-freebsd/lib/libthr/thread/thr_barrierattr.c >> http://nxr.netbsd.org/xref/src-freebsd/sys/kern/kern_umtx.c >> >> We don't have such mutex functionality in our kernel. Implementing this >> would be a GSoC project in itself. > > I don't think we want to use futexes in general. I'm not even sure I > care about performance for something horrible like "robust" mutexes at > all. A good starting point might to just extend the existing semaphores, > if necessary. > > Joerg >
Robust POSIX mutexes are now needed in the .NET platform to implement named mutexes: "Add named mutex for cross-process synchronization " https://github.com/dotnet/coreclr/commit/249221697fc5cf18c07566bac0e9f0eb6525218a I've opened an upstream issue to track this in NetBSD: " Robust POSIX mutexes unavailable on NetBSD #5128 " https://github.com/dotnet/coreclr/issues/5128 A short example of what is needed is presented here (CMake test extracted from the mentioned patch): #include <errno.h> #include <pthread.h> #include <time.h> int main() { pthread_mutexattr_t mutexAttributes; pthread_mutexattr_init(&mutexAttributes); pthread_mutexattr_setpshared(&mutexAttributes, PTHREAD_PROCESS_SHARED); pthread_mutexattr_settype(&mutexAttributes, PTHREAD_MUTEX_RECURSIVE); pthread_mutexattr_setrobust(&mutexAttributes, PTHREAD_MUTEX_ROBUST); pthread_mutex_t mutex; pthread_mutex_init(&mutex, &mutexAttributes); pthread_mutexattr_destroy(&mutexAttributes);+ struct timespec timeoutTime; timeoutTime.tv_sec = 1; // not the right way to specify absolute time, but just checking availability of timed lock timeoutTime.tv_nsec = 0; pthread_mutex_timedlock(&mutex, &timeoutTime); pthread_mutex_consistent(&mutex); pthread_mutex_destroy(&mutex); int error = EOWNERDEAD; error = ENOTRECOVERABLE; error = ETIMEDOUT; error = 0; return error; }