sdm: Set robust attribute on mutex object

Off-target SDM tests use a virtual driver which cancels
pthreads at the end of a test. We see instances where various
worker threads are left waiting on mutexes owned by threads that have
exited, although as per source code we are signalling the mutex before
cancel.

In order to robustly handle this situation, we want to set the robust attribute
on the pthread mutex when run in off-target mode. This will gracefully
set any such "orphaned" mutexes to signalled state so that other threads
are not blocked.

We are not setting this robust attribute for on-target version as robust
attribute comes with the requirement that users of pthread mutex
handle the case where owner is dead and transfer ownership explicitly
by calling pthread_make_consistent. Without this special handling, any
such orphaned mutexes will always remain in signalled state that can
cause synchronization to fail. Since this will impact existing
code, we want to limit the impact to off-target only. Please refer
man page for more details
http://manpages.ubuntu.com/manpages/bionic/man3/pthread_mutexattr_setrobust.3.html

Change-Id: I9005d9a8f996afb84b2f144c13db24d9cbe291b6
1 file changed