The Mutexgear library

Skip to first unread message

Oleh Derevenko

Aug 16, 2020, 9:45:47 AM8/16/20

Hi all,


I’ve once mentioned back in 2018 I’ve been granted a patent on implementing event synchronization by means of serializing synchronization.

I was planning to make the technology available for open source from the very beginning, it was a difficulty to compose a suitable license though. Some time ago I started publishing my library snapshots at GitHub (look for “Mutexgear”) and eventually I have created and added a license there. The license permits open source use without inclusion in shared libraries (read the text for details).

Even though the library is still in pre-release phase, there is no CMake build support added, there are no manuals and demos other than the test application and a few commented code fragments in include/mutexgear.h yet, and the test application itself is far from completely covering all the features, with recent additions of Automake scripts, I guess my work has reached the minimal level for the initial public presentation.


The library exports C interfaces for (I’ll copy a readme fragment here 😊)

  • mutexgear_toggle_t and mutexgear_wheel_t — mutex-only compound syncronization objects for signaling event type synchronization (similar to pthread_cond_t) with a restriction that the signaler must be a single thread pre-defined in advance (mainly, used for operation completion waits);
  • mutexgear_rwlock_t and mutexgear_trdl_rwlock_t — mutex-only RWLock implementations without and with try_rdlock support respectively (writer priority, inter-process support, all direction implied priority inheritance).
  • mutexgear_completion_queue_t and mutexgear_completion_cancelablequeue_t — multi-threaded server work queue skeletons with ability to wait for work item completion and, additionally, request and conduct work item handling cancellation.

The library uses C11 atomics internally but it can be reconfigured for custom atomic functions with preprocessor defines.

Also, the library contains header-only C++11 wrappers for its features.


The library includes pre-created solutions for Visual Studio 2013 and 2017, the former can be used as an example of compilation for targets without C11 support.

A recent performance test for mutexgear_rwlock_t versus pthread_rwlock_t (imported for the test application outputs) can be viewed at

Note that the substantially larger times for percentage read-write tests are caused by the writer priority feature (small number of writers are causing larger number of readers to go block into kernel to let the writers ahead)

Note also, that the test application runs a silent quick test by default and requires a command line switch to print times to the standard output and save operation dumps into files; also, privilege elevation may be required for the tests for changing to realtime priority class.


Oleh Derevenko

-- Skype with underscore
GPG Key Fingerprint: 2F56 32DC DCD9 B2BB 06E9 39E8 A37E 5E60 376E C691


Reply all
Reply to author
0 new messages