WL#5134: plugin service: mutexes, conditions, rwlocks

Affects: Server-6.0   —   Status: Assigned

Create services for pthread_mutex_* pthread_cond_* and pthread_rwlock_*

Plugins may want to use our mutex/cond/rwlock implementation instead of the
system one, because of built-in performance monitoring, deadlock detection,
identical API on all platforms, speed improvements, or other reasons.

Because the only proper way for plugins to use the server functionality is a
service, we should provide a service with locking primitives.
Q&A:

1. will we use pthread_mutex_* namespace (redefining OS mutexes) or a separate one ?

=> a separate one, my_mutex_*, redefining standard mutexes is too risky

2. will the whole server use my_mutex_* implementation or only plugins ?

=> in this WL - only plugins. performance_schema will introduce mutex wrappers
uniformly throughout the server, then using the same API internally and
externally can be reconsidered.

3. Can a mutex be created on the server and locked by a plugin or vice versa ?

=> Absolutely. That's the point. And this will be possible independent of the
server or plugin compilation options.
creating a service out of functions is straightforward.
But here we'll have data types - for example pthread_mutex_t - that we want to
have stable and independent from the internal implementation.

Possible solution - we'll export them as pointers

  typedef void* pthread_mutex_t;

and pthread_mutex_init will allocate the structure of necessary size.
Another possibility: define pthread_mutex_t as

  union { char buf[XXX]; void *align}

where XXX is big enough to fit any internal mutex representation.